Apply coding style
This commit is contained in:
@@ -51,39 +51,39 @@ typedef enum {
|
||||
ROSTER_CONTACT_UNREAD
|
||||
} roster_contact_theme_t;
|
||||
|
||||
static void _rosterwin_contacts_all(ProfLayoutSplit *layout);
|
||||
static void _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const presence, char *title);
|
||||
static void _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group);
|
||||
static void _rosteriwin_unsubscribed(ProfLayoutSplit *layout);
|
||||
static void _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *title, GSList *contacts);
|
||||
static void _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins);
|
||||
static void _rosterwin_contacts_all(ProfLayoutSplit* layout);
|
||||
static void _rosterwin_contacts_by_presence(ProfLayoutSplit* layout, const char* const presence, char* title);
|
||||
static void _rosterwin_contacts_by_group(ProfLayoutSplit* layout, char* group);
|
||||
static void _rosteriwin_unsubscribed(ProfLayoutSplit* layout);
|
||||
static void _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* title, GSList* contacts);
|
||||
static void _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins);
|
||||
|
||||
static void _rosterwin_contact(ProfLayoutSplit *layout, PContact contact);
|
||||
static void _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin);
|
||||
static void _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *status,
|
||||
int current_indent);
|
||||
static void _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent,
|
||||
roster_contact_theme_t theme_type, int unread);
|
||||
static void _rosterwin_contact(ProfLayoutSplit* layout, PContact contact);
|
||||
static void _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin);
|
||||
static void _rosterwin_presence(ProfLayoutSplit* layout, const char* presence, const char* status,
|
||||
int current_indent);
|
||||
static void _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_indent,
|
||||
roster_contact_theme_t theme_type, int unread);
|
||||
|
||||
static void _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms);
|
||||
static void _rosterwin_rooms_by_service(ProfLayoutSplit *layout);
|
||||
static void _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title);
|
||||
static void _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin);
|
||||
static void _rosterwin_print_rooms(ProfLayoutSplit *layout);
|
||||
static void _rosterwin_rooms(ProfLayoutSplit* layout, char* title, GList* rooms);
|
||||
static void _rosterwin_rooms_by_service(ProfLayoutSplit* layout);
|
||||
static void _rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title);
|
||||
static void _rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin);
|
||||
static void _rosterwin_print_rooms(ProfLayoutSplit* layout);
|
||||
|
||||
static void _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats);
|
||||
static void _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs);
|
||||
static void _rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats);
|
||||
static void _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs);
|
||||
|
||||
static GSList* _filter_contacts(GSList *contacts);
|
||||
static GSList* _filter_contacts_with_presence(GSList *contacts, const char *const presence);
|
||||
static theme_item_t _get_roster_theme(roster_contact_theme_t theme_type, const char *presence);
|
||||
static int _compare_rooms_name(ProfMucWin *a, ProfMucWin *b);
|
||||
static int _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b);
|
||||
static GSList* _filter_contacts(GSList* contacts);
|
||||
static GSList* _filter_contacts_with_presence(GSList* contacts, const char* const presence);
|
||||
static theme_item_t _get_roster_theme(roster_contact_theme_t theme_type, const char* presence);
|
||||
static int _compare_rooms_name(ProfMucWin* a, ProfMucWin* b);
|
||||
static int _compare_rooms_unread(ProfMucWin* a, ProfMucWin* b);
|
||||
|
||||
void
|
||||
rosterwin_roster(void)
|
||||
{
|
||||
ProfWin *console = wins_get_console();
|
||||
ProfWin* console = wins_get_console();
|
||||
if (!console) {
|
||||
return;
|
||||
}
|
||||
@@ -93,20 +93,20 @@ rosterwin_roster(void)
|
||||
return;
|
||||
}
|
||||
|
||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||
ProfLayoutSplit* layout = (ProfLayoutSplit*)console->layout;
|
||||
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||
werase(layout->subwin);
|
||||
|
||||
char *roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS);
|
||||
char* roomspos = prefs_get_string(PREF_ROSTER_ROOMS_POS);
|
||||
if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "first") == 0)) {
|
||||
_rosterwin_print_rooms(layout);
|
||||
|
||||
GList *orphaned_privchats = NULL;
|
||||
GList *privchats = wins_get_private_chats(NULL);
|
||||
GList *curr = privchats;
|
||||
GList* orphaned_privchats = NULL;
|
||||
GList* privchats = wins_get_private_chats(NULL);
|
||||
GList* curr = privchats;
|
||||
while (curr) {
|
||||
ProfPrivateWin *privwin = curr->data;
|
||||
Jid *jidp = jid_create(privwin->fulljid);
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
if (!muc_active(jidp->barejid)) {
|
||||
orphaned_privchats = g_list_append(orphaned_privchats, privwin);
|
||||
}
|
||||
@@ -114,17 +114,16 @@ rosterwin_roster(void)
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(privpref, "group") == 0 || orphaned_privchats) {
|
||||
_rosterwin_private_chats(layout, orphaned_privchats);
|
||||
}
|
||||
g_free(privpref);
|
||||
g_list_free(orphaned_privchats);
|
||||
|
||||
}
|
||||
|
||||
if (prefs_get_boolean(PREF_ROSTER_CONTACTS)) {
|
||||
char *by = prefs_get_string(PREF_ROSTER_BY);
|
||||
char* by = prefs_get_string(PREF_ROSTER_BY);
|
||||
if (g_strcmp0(by, "presence") == 0) {
|
||||
_rosterwin_contacts_by_presence(layout, "chat", "Available for chat");
|
||||
_rosterwin_contacts_by_presence(layout, "online", "Online");
|
||||
@@ -133,8 +132,8 @@ rosterwin_roster(void)
|
||||
_rosterwin_contacts_by_presence(layout, "dnd", "Do not disturb");
|
||||
_rosterwin_contacts_by_presence(layout, "offline", "Offline");
|
||||
} else if (g_strcmp0(by, "group") == 0) {
|
||||
GList *groups = roster_get_groups();
|
||||
GList *curr_group = groups;
|
||||
GList* groups = roster_get_groups();
|
||||
GList* curr_group = groups;
|
||||
while (curr_group) {
|
||||
_rosterwin_contacts_by_group(layout, curr_group->data);
|
||||
curr_group = g_list_next(curr_group);
|
||||
@@ -154,12 +153,12 @@ rosterwin_roster(void)
|
||||
if (prefs_get_boolean(PREF_ROSTER_ROOMS) && (g_strcmp0(roomspos, "last") == 0)) {
|
||||
_rosterwin_print_rooms(layout);
|
||||
|
||||
GList *orphaned_privchats = NULL;
|
||||
GList *privchats = wins_get_private_chats(NULL);
|
||||
GList *curr = privchats;
|
||||
GList* orphaned_privchats = NULL;
|
||||
GList* privchats = wins_get_private_chats(NULL);
|
||||
GList* curr = privchats;
|
||||
while (curr) {
|
||||
ProfPrivateWin *privwin = curr->data;
|
||||
Jid *jidp = jid_create(privwin->fulljid);
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
if (!muc_active(jidp->barejid)) {
|
||||
orphaned_privchats = g_list_append(orphaned_privchats, privwin);
|
||||
}
|
||||
@@ -167,7 +166,7 @@ rosterwin_roster(void)
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(privpref, "group") == 0 || orphaned_privchats) {
|
||||
_rosterwin_private_chats(layout, orphaned_privchats);
|
||||
}
|
||||
@@ -180,11 +179,11 @@ rosterwin_roster(void)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_contacts_all(ProfLayoutSplit *layout)
|
||||
_rosterwin_contacts_all(ProfLayoutSplit* layout)
|
||||
{
|
||||
GSList *contacts = NULL;
|
||||
GSList* contacts = NULL;
|
||||
|
||||
char *order = prefs_get_string(PREF_ROSTER_ORDER);
|
||||
char* order = prefs_get_string(PREF_ROSTER_ORDER);
|
||||
if (g_strcmp0(order, "presence") == 0) {
|
||||
contacts = roster_get_contacts(ROSTER_ORD_PRESENCE);
|
||||
} else {
|
||||
@@ -192,13 +191,13 @@ _rosterwin_contacts_all(ProfLayoutSplit *layout)
|
||||
}
|
||||
g_free(order);
|
||||
|
||||
GSList *filtered_contacts = _filter_contacts(contacts);
|
||||
GSList* filtered_contacts = _filter_contacts(contacts);
|
||||
g_slist_free(contacts);
|
||||
|
||||
_rosterwin_contacts_header(layout, "Roster", filtered_contacts);
|
||||
|
||||
if (filtered_contacts) {
|
||||
GSList *curr_contact = filtered_contacts;
|
||||
GSList* curr_contact = filtered_contacts;
|
||||
while (curr_contact) {
|
||||
PContact contact = curr_contact->data;
|
||||
_rosterwin_contact(layout, contact);
|
||||
@@ -209,16 +208,16 @@ _rosterwin_contacts_all(ProfLayoutSplit *layout)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosteriwin_unsubscribed(ProfLayoutSplit *layout)
|
||||
_rosteriwin_unsubscribed(ProfLayoutSplit* layout)
|
||||
{
|
||||
GList *wins = wins_get_chat_unsubscribed();
|
||||
GList* wins = wins_get_chat_unsubscribed();
|
||||
if (wins) {
|
||||
_rosterwin_unsubscribed_header(layout, wins);
|
||||
}
|
||||
|
||||
GList *curr = wins;
|
||||
GList* curr = wins;
|
||||
while (curr) {
|
||||
ProfChatWin *chatwin = curr->data;
|
||||
ProfChatWin* chatwin = curr->data;
|
||||
_rosterwin_unsubscribed_item(layout, chatwin);
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@@ -227,10 +226,10 @@ _rosteriwin_unsubscribed(ProfLayoutSplit *layout)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const presence, char *title)
|
||||
_rosterwin_contacts_by_presence(ProfLayoutSplit* layout, const char* const presence, char* title)
|
||||
{
|
||||
GSList *contacts = roster_get_contacts_by_presence(presence);
|
||||
GSList *filtered_contacts = _filter_contacts_with_presence(contacts, presence);
|
||||
GSList* contacts = roster_get_contacts_by_presence(presence);
|
||||
GSList* filtered_contacts = _filter_contacts_with_presence(contacts, presence);
|
||||
g_slist_free(contacts);
|
||||
|
||||
// if this group has contacts, or if we want to show empty groups
|
||||
@@ -239,7 +238,7 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese
|
||||
}
|
||||
|
||||
if (filtered_contacts) {
|
||||
GSList *curr_contact = filtered_contacts;
|
||||
GSList* curr_contact = filtered_contacts;
|
||||
while (curr_contact) {
|
||||
PContact contact = curr_contact->data;
|
||||
_rosterwin_contact(layout, contact);
|
||||
@@ -250,11 +249,11 @@ _rosterwin_contacts_by_presence(ProfLayoutSplit *layout, const char *const prese
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group)
|
||||
_rosterwin_contacts_by_group(ProfLayoutSplit* layout, char* group)
|
||||
{
|
||||
GSList *contacts = NULL;
|
||||
GSList* contacts = NULL;
|
||||
|
||||
char *order = prefs_get_string(PREF_ROSTER_ORDER);
|
||||
char* order = prefs_get_string(PREF_ROSTER_ORDER);
|
||||
if (g_strcmp0(order, "presence") == 0) {
|
||||
contacts = roster_get_group(group, ROSTER_ORD_PRESENCE);
|
||||
} else {
|
||||
@@ -262,7 +261,7 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group)
|
||||
}
|
||||
g_free(order);
|
||||
|
||||
GSList *filtered_contacts = _filter_contacts(contacts);
|
||||
GSList* filtered_contacts = _filter_contacts(contacts);
|
||||
g_slist_free(contacts);
|
||||
|
||||
if (filtered_contacts || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
|
||||
@@ -272,7 +271,7 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group)
|
||||
_rosterwin_contacts_header(layout, "no group", filtered_contacts);
|
||||
}
|
||||
|
||||
GSList *curr_contact = filtered_contacts;
|
||||
GSList* curr_contact = filtered_contacts;
|
||||
while (curr_contact) {
|
||||
PContact contact = curr_contact->data;
|
||||
_rosterwin_contact(layout, contact);
|
||||
@@ -283,10 +282,10 @@ _rosterwin_contacts_by_group(ProfLayoutSplit *layout, char *group)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin)
|
||||
_rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin)
|
||||
{
|
||||
const char *const name = chatwin->barejid;
|
||||
const char *const presence = "offline";
|
||||
const char* const name = chatwin->barejid;
|
||||
const char* const presence = "offline";
|
||||
int unread = 0;
|
||||
|
||||
roster_contact_theme_t theme_type = ROSTER_CONTACT;
|
||||
@@ -300,7 +299,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin)
|
||||
theme_item_t presence_colour = _get_roster_theme(theme_type, presence);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
GString *msg = g_string_new(" ");
|
||||
GString* msg = g_string_new(" ");
|
||||
int indent = prefs_get_roster_contact_indent();
|
||||
int current_indent = 0;
|
||||
if (indent > 0) {
|
||||
@@ -315,7 +314,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin)
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
}
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) {
|
||||
g_string_append_printf(msg, "(%d) ", unread);
|
||||
unread = 0;
|
||||
@@ -334,16 +333,16 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit *layout, ProfChatWin *chatwin)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
|
||||
_rosterwin_contact(ProfLayoutSplit* layout, PContact contact)
|
||||
{
|
||||
const char *name = p_contact_name_or_jid(contact);
|
||||
const char *presence = p_contact_presence(contact);
|
||||
const char *status = p_contact_status(contact);
|
||||
const char *barejid = p_contact_barejid(contact);
|
||||
const char* name = p_contact_name_or_jid(contact);
|
||||
const char* presence = p_contact_presence(contact);
|
||||
const char* status = p_contact_status(contact);
|
||||
const char* barejid = p_contact_barejid(contact);
|
||||
int unread = 0;
|
||||
|
||||
roster_contact_theme_t theme_type = ROSTER_CONTACT;
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
if (chatwin) {
|
||||
if (chatwin->unread > 0) {
|
||||
theme_type = ROSTER_CONTACT_UNREAD;
|
||||
@@ -362,7 +361,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
}
|
||||
|
||||
GString *msg = g_string_new(" ");
|
||||
GString* msg = g_string_new(" ");
|
||||
int indent = prefs_get_roster_contact_indent();
|
||||
int current_indent = 0;
|
||||
if (indent > 0) {
|
||||
@@ -377,7 +376,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
}
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "before") == 0) && unread > 0) {
|
||||
g_string_append_printf(msg, "(%d) ", unread);
|
||||
unread = 0;
|
||||
@@ -408,7 +407,7 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
|
||||
_rosterwin_resources(layout, contact, current_indent, theme_type, unread);
|
||||
} else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) {
|
||||
if (unread > 0) {
|
||||
GString *unreadmsg = g_string_new("");
|
||||
GString* unreadmsg = g_string_new("");
|
||||
g_string_append_printf(unreadmsg, " (%d)", unread);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
@@ -422,8 +421,8 @@ _rosterwin_contact(ProfLayoutSplit *layout, PContact contact)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *status,
|
||||
int current_indent)
|
||||
_rosterwin_presence(ProfLayoutSplit* layout, const char* presence, const char* status,
|
||||
int current_indent)
|
||||
{
|
||||
// don't show presence for offline contacts
|
||||
gboolean is_offline = g_strcmp0(presence, "offline") == 0;
|
||||
@@ -431,7 +430,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s
|
||||
return;
|
||||
}
|
||||
|
||||
char *by = prefs_get_string(PREF_ROSTER_BY);
|
||||
char* by = prefs_get_string(PREF_ROSTER_BY);
|
||||
gboolean by_presence = g_strcmp0(by, "presence") == 0;
|
||||
g_free(by);
|
||||
|
||||
@@ -449,13 +448,13 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s
|
||||
|
||||
wattron(layout->subwin, theme_attrs(colour));
|
||||
if (presence_indent == -1) {
|
||||
GString *msg = g_string_new("");
|
||||
GString* msg = g_string_new("");
|
||||
g_string_append_printf(msg, ": \"%s\"", status);
|
||||
win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
|
||||
g_string_free(msg, TRUE);
|
||||
wattroff(layout->subwin, theme_attrs(colour));
|
||||
} else {
|
||||
GString *msg = g_string_new(" ");
|
||||
GString* msg = g_string_new(" ");
|
||||
while (current_indent > 0) {
|
||||
g_string_append(msg, " ");
|
||||
current_indent--;
|
||||
@@ -468,11 +467,11 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s
|
||||
}
|
||||
}
|
||||
|
||||
// show both presence and status when not grouped by presence
|
||||
// show both presence and status when not grouped by presence
|
||||
} else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || (status && prefs_get_boolean(PREF_ROSTER_STATUS))) {
|
||||
wattron(layout->subwin, theme_attrs(colour));
|
||||
if (presence_indent == -1) {
|
||||
GString *msg = g_string_new("");
|
||||
GString* msg = g_string_new("");
|
||||
if (prefs_get_boolean(PREF_ROSTER_PRESENCE)) {
|
||||
g_string_append_printf(msg, ": %s", presence);
|
||||
if (status && prefs_get_boolean(PREF_ROSTER_STATUS)) {
|
||||
@@ -485,7 +484,7 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s
|
||||
g_string_free(msg, TRUE);
|
||||
wattroff(layout->subwin, theme_attrs(colour));
|
||||
} else {
|
||||
GString *msg = g_string_new(" ");
|
||||
GString* msg = g_string_new(" ");
|
||||
while (current_indent > 0) {
|
||||
g_string_append(msg, " ");
|
||||
current_indent--;
|
||||
@@ -507,22 +506,22 @@ _rosterwin_presence(ProfLayoutSplit *layout, const char *presence, const char *s
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_indent, roster_contact_theme_t theme_type,
|
||||
int unread)
|
||||
_rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_indent, roster_contact_theme_t theme_type,
|
||||
int unread)
|
||||
{
|
||||
gboolean join = prefs_get_boolean(PREF_ROSTER_RESOURCE_JOIN);
|
||||
|
||||
GList *resources = p_contact_get_available_resources(contact);
|
||||
GList* resources = p_contact_get_available_resources(contact);
|
||||
if (resources) {
|
||||
|
||||
// resource on same line as contact
|
||||
if (join && (g_list_length(resources) == 1)) {
|
||||
Resource *resource = resources->data;
|
||||
const char *resource_presence = string_from_resource_presence(resource->presence);
|
||||
Resource* resource = resources->data;
|
||||
const char* resource_presence = string_from_resource_presence(resource->presence);
|
||||
theme_item_t resource_presence_colour = _get_roster_theme(theme_type, resource_presence);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(resource_presence_colour));
|
||||
GString *msg = g_string_new("");
|
||||
GString* msg = g_string_new("");
|
||||
char ch = prefs_get_roster_resource_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
@@ -534,7 +533,7 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
|
||||
g_string_append_printf(msg, " %d", resource->priority);
|
||||
}
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
|
||||
g_string_append_printf(msg, " (%d)", unread);
|
||||
}
|
||||
@@ -549,16 +548,16 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
|
||||
_rosterwin_presence(layout, resource_presence, resource->status, current_indent);
|
||||
}
|
||||
|
||||
// resource(s) on new lines
|
||||
// resource(s) on new lines
|
||||
} else {
|
||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
|
||||
GString *unreadmsg = g_string_new("");
|
||||
GString* unreadmsg = g_string_new("");
|
||||
g_string_append_printf(unreadmsg, " (%d)", unread);
|
||||
|
||||
const char *presence = p_contact_presence(contact);
|
||||
const char* presence = p_contact_presence(contact);
|
||||
theme_item_t presence_colour = _get_roster_theme(theme_type, presence);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
@@ -573,14 +572,14 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
|
||||
current_indent += resource_indent;
|
||||
}
|
||||
|
||||
GList *curr_resource = resources;
|
||||
GList* curr_resource = resources;
|
||||
while (curr_resource) {
|
||||
Resource *resource = curr_resource->data;
|
||||
const char *resource_presence = string_from_resource_presence(resource->presence);
|
||||
Resource* resource = curr_resource->data;
|
||||
const char* resource_presence = string_from_resource_presence(resource->presence);
|
||||
theme_item_t resource_presence_colour = _get_roster_theme(ROSTER_CONTACT, resource_presence);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(resource_presence_colour));
|
||||
GString *msg = g_string_new(" ");
|
||||
GString* msg = g_string_new(" ");
|
||||
int this_indent = current_indent;
|
||||
while (this_indent > 0) {
|
||||
g_string_append(msg, " ");
|
||||
@@ -607,14 +606,14 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
|
||||
}
|
||||
}
|
||||
} else if (prefs_get_boolean(PREF_ROSTER_PRESENCE) || prefs_get_boolean(PREF_ROSTER_STATUS)) {
|
||||
const char *presence = p_contact_presence(contact);
|
||||
const char *status = p_contact_status(contact);
|
||||
const char* presence = p_contact_presence(contact);
|
||||
const char* status = p_contact_status(contact);
|
||||
theme_item_t presence_colour = _get_roster_theme(theme_type, presence);
|
||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
|
||||
GString *unreadmsg = g_string_new("");
|
||||
GString* unreadmsg = g_string_new("");
|
||||
g_string_append_printf(unreadmsg, " (%d)", unread);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
@@ -627,11 +626,11 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
|
||||
} else {
|
||||
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && unread > 0) {
|
||||
GString *unreadmsg = g_string_new("");
|
||||
GString* unreadmsg = g_string_new("");
|
||||
g_string_append_printf(unreadmsg, " (%d)", unread);
|
||||
const char *presence = p_contact_presence(contact);
|
||||
const char* presence = p_contact_presence(contact);
|
||||
theme_item_t presence_colour = _get_roster_theme(theme_type, presence);
|
||||
|
||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||
@@ -643,18 +642,17 @@ _rosterwin_resources(ProfLayoutSplit *layout, PContact contact, int current_inde
|
||||
}
|
||||
|
||||
g_list_free(resources);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
|
||||
_rosterwin_rooms(ProfLayoutSplit* layout, char* title, GList* rooms)
|
||||
{
|
||||
GList *rooms_sorted = NULL;
|
||||
GList *curr_room = rooms;
|
||||
GList* rooms_sorted = NULL;
|
||||
GList* curr_room = rooms;
|
||||
while (curr_room) {
|
||||
ProfMucWin *mucwin = wins_get_muc(curr_room->data);
|
||||
ProfMucWin* mucwin = wins_get_muc(curr_room->data);
|
||||
if (mucwin) {
|
||||
char *order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER);
|
||||
char* order = prefs_get_string(PREF_ROSTER_ROOMS_ORDER);
|
||||
if (g_strcmp0(order, "unread") == 0) {
|
||||
rooms_sorted = g_list_insert_sorted(rooms_sorted, mucwin, (GCompareFunc)_compare_rooms_unread);
|
||||
} else {
|
||||
@@ -669,7 +667,7 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
|
||||
if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
|
||||
_rosterwin_rooms_header(layout, rooms_sorted, title);
|
||||
|
||||
GList *curr_room = rooms_sorted;
|
||||
GList* curr_room = rooms_sorted;
|
||||
while (curr_room) {
|
||||
_rosterwin_room(layout, curr_room->data);
|
||||
curr_room = g_list_next(curr_room);
|
||||
@@ -680,14 +678,14 @@ _rosterwin_rooms(ProfLayoutSplit *layout, char *title, GList *rooms)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_rooms_by_service(ProfLayoutSplit *layout)
|
||||
_rosterwin_rooms_by_service(ProfLayoutSplit* layout)
|
||||
{
|
||||
GList *rooms = muc_rooms();
|
||||
GList *curr = rooms;
|
||||
GList *services = NULL;
|
||||
GList* rooms = muc_rooms();
|
||||
GList* curr = rooms;
|
||||
GList* services = NULL;
|
||||
while (curr) {
|
||||
char *roomjid = curr->data;
|
||||
Jid *jidp = jid_create(roomjid);
|
||||
char* roomjid = curr->data;
|
||||
Jid* jidp = jid_create(roomjid);
|
||||
|
||||
if (!g_list_find_custom(services, jidp->domainpart, (GCompareFunc)g_strcmp0)) {
|
||||
services = g_list_insert_sorted(services, strdup(jidp->domainpart), (GCompareFunc)g_strcmp0);
|
||||
@@ -697,15 +695,15 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout)
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
GList *curr_service = services;
|
||||
GList* curr_service = services;
|
||||
while (curr_service) {
|
||||
char *service = curr_service->data;
|
||||
GList *filtered_rooms = NULL;
|
||||
char* service = curr_service->data;
|
||||
GList* filtered_rooms = NULL;
|
||||
|
||||
curr = rooms;
|
||||
while (curr) {
|
||||
char *roomjid = curr->data;
|
||||
Jid *jidp = jid_create(roomjid);
|
||||
char* roomjid = curr->data;
|
||||
Jid* jidp = jid_create(roomjid);
|
||||
|
||||
if (g_strcmp0(curr_service->data, jidp->domainpart) == 0) {
|
||||
filtered_rooms = g_list_append(filtered_rooms, strdup(jidp->barejid));
|
||||
@@ -726,9 +724,9 @@ _rosterwin_rooms_by_service(ProfLayoutSplit *layout)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
_rosterwin_room(ProfLayoutSplit* layout, ProfMucWin* mucwin)
|
||||
{
|
||||
GString *msg = g_string_new(" ");
|
||||
GString* msg = g_string_new(" ");
|
||||
|
||||
if (mucwin->unread_mentions) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION));
|
||||
@@ -754,17 +752,17 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
g_string_append_printf(msg, "%c", ch);
|
||||
}
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "before") == 0) && mucwin->unread > 0) {
|
||||
g_string_append_printf(msg, "(%d) ", mucwin->unread);
|
||||
}
|
||||
|
||||
char *use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME);
|
||||
char *roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
char* use_as_name = prefs_get_string(PREF_ROSTER_ROOMS_USE_AS_NAME);
|
||||
char* roombypref = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
|
||||
if (g_strcmp0(roombypref, "service") == 0) {
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
Jid *jidp = jid_create(mucwin->roomjid);
|
||||
Jid* jidp = jid_create(mucwin->roomjid);
|
||||
g_string_append(msg, jidp->localpart);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
@@ -780,10 +778,9 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
}
|
||||
} else {
|
||||
Jid *jidp = jid_create(mucwin->roomjid);
|
||||
Jid* jidp = jid_create(mucwin->roomjid);
|
||||
|
||||
if (mucwin->room_name == NULL ||
|
||||
(g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
if (mucwin->room_name == NULL || (g_strcmp0(use_as_name, "jid") == 0)) {
|
||||
g_string_append(msg, jidp->localpart);
|
||||
} else {
|
||||
g_string_append(msg, mucwin->room_name);
|
||||
@@ -816,15 +813,15 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
|
||||
}
|
||||
|
||||
char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(privpref, "room") == 0) {
|
||||
GList *privs = wins_get_private_chats(mucwin->roomjid);
|
||||
GList *curr = privs;
|
||||
GList* privs = wins_get_private_chats(mucwin->roomjid);
|
||||
GList* curr = privs;
|
||||
while (curr) {
|
||||
ProfPrivateWin *privwin = curr->data;
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString *privmsg = g_string_new(" ");
|
||||
GString* privmsg = g_string_new(" ");
|
||||
indent = prefs_get_roster_contact_indent();
|
||||
current_indent = 0;
|
||||
if (indent > 0) {
|
||||
@@ -855,7 +852,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
g_string_append_printf(privmsg, "%c", ch);
|
||||
}
|
||||
|
||||
char *nick = privwin->fulljid + strlen(mucwin->roomjid) + 1;
|
||||
char* nick = privwin->fulljid + strlen(mucwin->roomjid) + 1;
|
||||
g_string_append(privmsg, nick);
|
||||
|
||||
if ((g_strcmp0(unreadpos, "after") == 0) && privwin->unread > 0) {
|
||||
@@ -863,9 +860,9 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
}
|
||||
g_free(unreadpos);
|
||||
|
||||
const char *presence = "offline";
|
||||
const char* presence = "offline";
|
||||
|
||||
Occupant *occupant = muc_roster_item(mucwin->roomjid, nick);
|
||||
Occupant* occupant = muc_roster_item(mucwin->roomjid, nick);
|
||||
if (occupant) {
|
||||
presence = string_from_resource_presence(occupant->presence);
|
||||
}
|
||||
@@ -892,13 +889,13 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_print_rooms(ProfLayoutSplit *layout)
|
||||
_rosterwin_print_rooms(ProfLayoutSplit* layout)
|
||||
{
|
||||
char *roomsbypref = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
char* roomsbypref = prefs_get_string(PREF_ROSTER_ROOMS_BY);
|
||||
if (g_strcmp0(roomsbypref, "service") == 0) {
|
||||
_rosterwin_rooms_by_service(layout);
|
||||
} else {
|
||||
GList *rooms = muc_rooms();
|
||||
GList* rooms = muc_rooms();
|
||||
_rosterwin_rooms(layout, "Rooms", rooms);
|
||||
g_list_free(rooms);
|
||||
}
|
||||
@@ -906,15 +903,15 @@ _rosterwin_print_rooms(ProfLayoutSplit *layout)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats)
|
||||
_rosterwin_private_chats(ProfLayoutSplit* layout, GList* orphaned_privchats)
|
||||
{
|
||||
GList *privs = NULL;
|
||||
GList* privs = NULL;
|
||||
|
||||
char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
char* privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(privpref, "group") == 0) {
|
||||
privs = wins_get_private_chats(NULL);
|
||||
} else {
|
||||
GList *curr = orphaned_privchats;
|
||||
GList* curr = orphaned_privchats;
|
||||
while (curr) {
|
||||
privs = g_list_append(privs, curr->data);
|
||||
curr = g_list_next(curr);
|
||||
@@ -924,12 +921,12 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats)
|
||||
if (privs || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
|
||||
_rosterwin_private_header(layout, privs);
|
||||
|
||||
GList *curr = privs;
|
||||
GList* curr = privs;
|
||||
while (curr) {
|
||||
ProfPrivateWin *privwin = curr->data;
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString *privmsg = g_string_new(" ");
|
||||
GString* privmsg = g_string_new(" ");
|
||||
int indent = prefs_get_roster_contact_indent();
|
||||
int current_indent = 0;
|
||||
if (indent > 0) {
|
||||
@@ -940,7 +937,7 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats)
|
||||
}
|
||||
}
|
||||
|
||||
char *unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD);
|
||||
char* unreadpos = prefs_get_string(PREF_ROSTER_ROOMS_UNREAD);
|
||||
if ((g_strcmp0(unreadpos, "before") == 0) && privwin->unread > 0) {
|
||||
g_string_append_printf(privmsg, "(%d) ", privwin->unread);
|
||||
}
|
||||
@@ -957,11 +954,11 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats)
|
||||
}
|
||||
g_free(unreadpos);
|
||||
|
||||
Jid *jidp = jid_create(privwin->fulljid);
|
||||
Occupant *occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
|
||||
Jid* jidp = jid_create(privwin->fulljid);
|
||||
Occupant* occupant = muc_roster_item(jidp->barejid, jidp->resourcepart);
|
||||
jid_destroy(jidp);
|
||||
|
||||
const char *presence = "offline";
|
||||
const char* presence = "offline";
|
||||
if (occupant) {
|
||||
presence = string_from_resource_presence(occupant->presence);
|
||||
}
|
||||
@@ -988,24 +985,28 @@ _rosterwin_private_chats(ProfLayoutSplit *layout, GList *orphaned_privchats)
|
||||
}
|
||||
|
||||
static theme_item_t
|
||||
_get_roster_theme(roster_contact_theme_t theme_type, const char *presence)
|
||||
_get_roster_theme(roster_contact_theme_t theme_type, const char* presence)
|
||||
{
|
||||
switch (theme_type) {
|
||||
case ROSTER_CONTACT: return theme_roster_presence_attrs(presence);
|
||||
case ROSTER_CONTACT_ACTIVE: return theme_roster_active_presence_attrs(presence);
|
||||
case ROSTER_CONTACT_UNREAD: return theme_roster_unread_presence_attrs(presence);
|
||||
default: return theme_roster_presence_attrs(presence);
|
||||
case ROSTER_CONTACT:
|
||||
return theme_roster_presence_attrs(presence);
|
||||
case ROSTER_CONTACT_ACTIVE:
|
||||
return theme_roster_active_presence_attrs(presence);
|
||||
case ROSTER_CONTACT_UNREAD:
|
||||
return theme_roster_unread_presence_attrs(presence);
|
||||
default:
|
||||
return theme_roster_presence_attrs(presence);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_compare_rooms_name(ProfMucWin *a, ProfMucWin *b)
|
||||
_compare_rooms_name(ProfMucWin* a, ProfMucWin* b)
|
||||
{
|
||||
return g_strcmp0(a->roomjid, b->roomjid);
|
||||
}
|
||||
|
||||
static int
|
||||
_compare_rooms_unread(ProfMucWin *a, ProfMucWin *b)
|
||||
_compare_rooms_unread(ProfMucWin* a, ProfMucWin* b)
|
||||
{
|
||||
if (a->unread > b->unread) {
|
||||
return -1;
|
||||
@@ -1017,11 +1018,11 @@ _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins)
|
||||
_rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins)
|
||||
{
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString *header = g_string_new(" ");
|
||||
GString* header = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(header, "%c", ch);
|
||||
@@ -1029,7 +1030,7 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins)
|
||||
|
||||
g_string_append(header, "Unsubscribed");
|
||||
|
||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
char* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int itemcount = g_list_length(wins);
|
||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
@@ -1039,9 +1040,9 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins)
|
||||
}
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
int unreadcount = 0;
|
||||
GList *curr = wins;
|
||||
GList* curr = wins;
|
||||
while (curr) {
|
||||
ProfChatWin *chatwin = curr->data;
|
||||
ProfChatWin* chatwin = curr->data;
|
||||
unreadcount += chatwin->unread;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@@ -1063,11 +1064,11 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit *layout, GList *wins)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSList *contacts)
|
||||
_rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSList* contacts)
|
||||
{
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString *header = g_string_new(" ");
|
||||
GString* header = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(header, "%c", ch);
|
||||
@@ -1075,7 +1076,7 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL
|
||||
|
||||
g_string_append(header, title);
|
||||
|
||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
char* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int itemcount = g_slist_length(contacts);
|
||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
@@ -1085,11 +1086,11 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL
|
||||
}
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
int unreadcount = 0;
|
||||
GSList *curr = contacts;
|
||||
GSList* curr = contacts;
|
||||
while (curr) {
|
||||
PContact contact = curr->data;
|
||||
const char *barejid = p_contact_barejid(contact);
|
||||
ProfChatWin *chatwin = wins_get_chat(barejid);
|
||||
const char* barejid = p_contact_barejid(contact);
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
if (chatwin) {
|
||||
unreadcount += chatwin->unread;
|
||||
}
|
||||
@@ -1113,17 +1114,17 @@ _rosterwin_contacts_header(ProfLayoutSplit *layout, const char *const title, GSL
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title)
|
||||
_rosterwin_rooms_header(ProfLayoutSplit* layout, GList* rooms, char* title)
|
||||
{
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
GString *header = g_string_new(" ");
|
||||
GString* header = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(header, "%c", ch);
|
||||
}
|
||||
g_string_append(header, title);
|
||||
|
||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
char* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int count = g_list_length(rooms);
|
||||
if (count == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
@@ -1133,18 +1134,18 @@ _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title)
|
||||
}
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
int unread = 0;
|
||||
GList *curr = rooms;
|
||||
GList* curr = rooms;
|
||||
while (curr) {
|
||||
ProfMucWin *mucwin = curr->data;
|
||||
ProfMucWin* mucwin = curr->data;
|
||||
unread += mucwin->unread;
|
||||
|
||||
// include private chats
|
||||
char *prefpriv = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
char* prefpriv = prefs_get_string(PREF_ROSTER_PRIVATE);
|
||||
if (g_strcmp0(prefpriv, "room") == 0) {
|
||||
GList *privwins = wins_get_private_chats(mucwin->roomjid);
|
||||
GList *curr_priv = privwins;
|
||||
GList* privwins = wins_get_private_chats(mucwin->roomjid);
|
||||
GList* curr_priv = privwins;
|
||||
while (curr_priv) {
|
||||
ProfPrivateWin *privwin = curr_priv->data;
|
||||
ProfPrivateWin* privwin = curr_priv->data;
|
||||
unread += privwin->unread;
|
||||
curr_priv = g_list_next(curr_priv);
|
||||
}
|
||||
@@ -1173,18 +1174,18 @@ _rosterwin_rooms_header(ProfLayoutSplit *layout, GList *rooms, char *title)
|
||||
}
|
||||
|
||||
static void
|
||||
_rosterwin_private_header(ProfLayoutSplit *layout, GList *privs)
|
||||
_rosterwin_private_header(ProfLayoutSplit* layout, GList* privs)
|
||||
{
|
||||
win_sub_newline_lazy(layout->subwin);
|
||||
|
||||
GString *title_str = g_string_new(" ");
|
||||
GString* title_str = g_string_new(" ");
|
||||
char ch = prefs_get_roster_header_char();
|
||||
if (ch) {
|
||||
g_string_append_printf(title_str, "%c", ch);
|
||||
}
|
||||
g_string_append(title_str, "Private chats");
|
||||
|
||||
char *countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
char* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int itemcount = g_list_length(privs);
|
||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
@@ -1194,9 +1195,9 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs)
|
||||
}
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
int unreadcount = 0;
|
||||
GList *curr = privs;
|
||||
GList* curr = privs;
|
||||
while (curr) {
|
||||
ProfPrivateWin *privwin = curr->data;
|
||||
ProfPrivateWin* privwin = curr->data;
|
||||
unreadcount += privwin->unread;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@@ -1218,32 +1219,32 @@ _rosterwin_private_header(ProfLayoutSplit *layout, GList *privs)
|
||||
}
|
||||
|
||||
static GSList*
|
||||
_filter_contacts(GSList *contacts)
|
||||
_filter_contacts(GSList* contacts)
|
||||
{
|
||||
GSList *filtered_contacts = NULL;
|
||||
GSList* filtered_contacts = NULL;
|
||||
|
||||
// if show offline, include all contacts
|
||||
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
||||
GSList *curr = contacts;
|
||||
GSList* curr = contacts;
|
||||
while (curr) {
|
||||
filtered_contacts = g_slist_append(filtered_contacts, curr->data);
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
// if dont show offline
|
||||
// if dont show offline
|
||||
} else {
|
||||
GSList *curr = contacts;
|
||||
GSList* curr = contacts;
|
||||
while (curr) {
|
||||
PContact contact = curr->data;
|
||||
const char *presence = p_contact_presence(contact);
|
||||
const char* presence = p_contact_presence(contact);
|
||||
|
||||
// include if offline and unread messages
|
||||
if (g_strcmp0(presence, "offline") == 0) {
|
||||
ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact));
|
||||
ProfChatWin* chatwin = wins_get_chat(p_contact_barejid(contact));
|
||||
if (chatwin && chatwin->unread > 0) {
|
||||
filtered_contacts = g_slist_append(filtered_contacts, contact);
|
||||
}
|
||||
|
||||
// include if not offline
|
||||
// include if not offline
|
||||
} else {
|
||||
filtered_contacts = g_slist_append(filtered_contacts, contact);
|
||||
}
|
||||
@@ -1255,27 +1256,27 @@ _filter_contacts(GSList *contacts)
|
||||
}
|
||||
|
||||
static GSList*
|
||||
_filter_contacts_with_presence(GSList *contacts, const char *const presence)
|
||||
_filter_contacts_with_presence(GSList* contacts, const char* const presence)
|
||||
{
|
||||
GSList *filtered_contacts = NULL;
|
||||
GSList* filtered_contacts = NULL;
|
||||
|
||||
// handling offline contacts
|
||||
if (g_strcmp0(presence, "offline") == 0) {
|
||||
|
||||
// if show offline, include all contacts
|
||||
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
||||
GSList *curr = contacts;
|
||||
GSList* curr = contacts;
|
||||
while (curr) {
|
||||
filtered_contacts = g_slist_append(filtered_contacts, curr->data);
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
|
||||
// otherwise show if unread messages
|
||||
// otherwise show if unread messages
|
||||
} else {
|
||||
GSList *curr = contacts;
|
||||
GSList* curr = contacts;
|
||||
while (curr) {
|
||||
PContact contact = curr->data;
|
||||
ProfChatWin *chatwin = wins_get_chat(p_contact_barejid(contact));
|
||||
ProfChatWin* chatwin = wins_get_chat(p_contact_barejid(contact));
|
||||
if (chatwin && chatwin->unread > 0) {
|
||||
filtered_contacts = g_slist_append(filtered_contacts, contact);
|
||||
}
|
||||
@@ -1283,9 +1284,9 @@ _filter_contacts_with_presence(GSList *contacts, const char *const presence)
|
||||
}
|
||||
}
|
||||
|
||||
// any other presence, include all
|
||||
// any other presence, include all
|
||||
} else {
|
||||
GSList *curr = contacts;
|
||||
GSList* curr = contacts;
|
||||
while (curr) {
|
||||
filtered_contacts = g_slist_append(filtered_contacts, curr->data);
|
||||
curr = g_slist_next(curr);
|
||||
|
||||
Reference in New Issue
Block a user