mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Moved roster functions
This commit is contained in:
parent
0e7e931589
commit
48ec7b3b47
@ -18,7 +18,7 @@ core_sources = \
|
|||||||
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
|
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
|
||||||
src/ui/console.c src/ui/notifier.c \
|
src/ui/console.c src/ui/notifier.c \
|
||||||
src/ui/windows.c src/ui/windows.h \
|
src/ui/windows.c src/ui/windows.h \
|
||||||
src/ui/rosterwin.c src/ui/rosterwin.h \
|
src/ui/rosterwin.c \
|
||||||
src/ui/buffer.c src/ui/buffer.h \
|
src/ui/buffer.c src/ui/buffer.h \
|
||||||
src/command/command.h src/command/command.c src/command/history.c \
|
src/command/command.h src/command/command.c src/command/history.c \
|
||||||
src/command/commands.h src/command/commands.c \
|
src/command/commands.h src/command/commands.c \
|
||||||
@ -57,7 +57,6 @@ tests_sources = \
|
|||||||
src/config/theme.c src/config/theme.h \
|
src/config/theme.c src/config/theme.h \
|
||||||
src/ui/windows.c src/ui/windows.h \
|
src/ui/windows.c src/ui/windows.h \
|
||||||
src/ui/window.c src/ui/window.h \
|
src/ui/window.c src/ui/window.h \
|
||||||
src/ui/rosterwin.c src/ui/rosterwin.h \
|
|
||||||
src/ui/buffer.c \
|
src/ui/buffer.c \
|
||||||
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
|
src/ui/titlebar.c src/ui/statusbar.c src/ui/inputwin.c \
|
||||||
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
|
src/ui/titlebar.h src/ui/statusbar.h src/ui/inputwin.h \
|
||||||
|
@ -1405,12 +1405,12 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
|||||||
} else if (g_strcmp0(args[1], "offline") == 0) {
|
} else if (g_strcmp0(args[1], "offline") == 0) {
|
||||||
cons_show("Roster offline enabled");
|
cons_show("Roster offline enabled");
|
||||||
prefs_set_boolean(PREF_ROSTER_OFFLINE, TRUE);
|
prefs_set_boolean(PREF_ROSTER_OFFLINE, TRUE);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[1], "resource") == 0) {
|
} else if (g_strcmp0(args[1], "resource") == 0) {
|
||||||
cons_show("Roster resource enabled");
|
cons_show("Roster resource enabled");
|
||||||
prefs_set_boolean(PREF_ROSTER_RESOURCE, TRUE);
|
prefs_set_boolean(PREF_ROSTER_RESOURCE, TRUE);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
@ -1425,12 +1425,12 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
|||||||
} else if (g_strcmp0(args[1], "offline") == 0) {
|
} else if (g_strcmp0(args[1], "offline") == 0) {
|
||||||
cons_show("Roster offline disabled");
|
cons_show("Roster offline disabled");
|
||||||
prefs_set_boolean(PREF_ROSTER_OFFLINE, FALSE);
|
prefs_set_boolean(PREF_ROSTER_OFFLINE, FALSE);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[1], "resource") == 0) {
|
} else if (g_strcmp0(args[1], "resource") == 0) {
|
||||||
cons_show("Roster resource disabled");
|
cons_show("Roster resource disabled");
|
||||||
prefs_set_boolean(PREF_ROSTER_RESOURCE, FALSE);
|
prefs_set_boolean(PREF_ROSTER_RESOURCE, FALSE);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
@ -1441,17 +1441,17 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
|||||||
if (g_strcmp0(args[1], "group") == 0) {
|
if (g_strcmp0(args[1], "group") == 0) {
|
||||||
cons_show("Grouping roster by roster group");
|
cons_show("Grouping roster by roster group");
|
||||||
prefs_set_string(PREF_ROSTER_BY, "group");
|
prefs_set_string(PREF_ROSTER_BY, "group");
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[1], "presence") == 0) {
|
} else if (g_strcmp0(args[1], "presence") == 0) {
|
||||||
cons_show("Grouping roster by presence");
|
cons_show("Grouping roster by presence");
|
||||||
prefs_set_string(PREF_ROSTER_BY, "presence");
|
prefs_set_string(PREF_ROSTER_BY, "presence");
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (g_strcmp0(args[1], "none") == 0) {
|
} else if (g_strcmp0(args[1], "none") == 0) {
|
||||||
cons_show("Roster grouping disabled");
|
cons_show("Roster grouping disabled");
|
||||||
prefs_set_string(PREF_ROSTER_BY, "none");
|
prefs_set_string(PREF_ROSTER_BY, "none");
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
|
@ -68,6 +68,7 @@ _init_modules(void)
|
|||||||
ui_init_module();
|
ui_init_module();
|
||||||
console_init_module();
|
console_init_module();
|
||||||
notifier_init_module();
|
notifier_init_module();
|
||||||
|
rosterwin_init_module();
|
||||||
|
|
||||||
accounts_init_module();
|
accounts_init_module();
|
||||||
#ifdef HAVE_LIBOTR
|
#ifdef HAVE_LIBOTR
|
||||||
|
@ -464,7 +464,7 @@ handle_contact_offline(char *barejid, char *resource, char *status)
|
|||||||
jid_destroy(jid);
|
jid_destroy(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -506,7 +506,7 @@ handle_contact_online(char *barejid, Resource *resource,
|
|||||||
prefs_free_string(show_chat_win);
|
prefs_free_string(show_chat_win);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -638,7 +638,7 @@ handle_roster_update(const char * const barejid, const char * const name,
|
|||||||
GSList *groups, const char * const subscription, gboolean pending_out)
|
GSList *groups, const char * const subscription, gboolean pending_out)
|
||||||
{
|
{
|
||||||
roster_update(barejid, name, groups, subscription, pending_out);
|
roster_update(barejid, name, groups, subscription, pending_out);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
129
src/ui/core.c
129
src/ui/core.c
@ -69,7 +69,6 @@
|
|||||||
#include "ui/inputwin.h"
|
#include "ui/inputwin.h"
|
||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
#include "ui/windows.h"
|
#include "ui/windows.h"
|
||||||
#include "ui/rosterwin.h"
|
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
|
|
||||||
static char *win_title;
|
static char *win_title;
|
||||||
@ -466,42 +465,42 @@ _ui_roster_add(const char * const barejid, const char * const name)
|
|||||||
} else {
|
} else {
|
||||||
cons_show("Roster item added: %s", barejid);
|
cons_show("Roster item added: %s", barejid);
|
||||||
}
|
}
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_roster_remove(const char * const barejid)
|
_ui_roster_remove(const char * const barejid)
|
||||||
{
|
{
|
||||||
cons_show("Roster item removed: %s", barejid);
|
cons_show("Roster item removed: %s", barejid);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_contact_already_in_group(const char * const contact, const char * const group)
|
_ui_contact_already_in_group(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s already in group %s", contact, group);
|
cons_show("%s already in group %s", contact, group);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_contact_not_in_group(const char * const contact, const char * const group)
|
_ui_contact_not_in_group(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s is not currently in group %s", contact, group);
|
cons_show("%s is not currently in group %s", contact, group);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_group_added(const char * const contact, const char * const group)
|
_ui_group_added(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s added to group %s", contact, group);
|
cons_show("%s added to group %s", contact, group);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_group_removed(const char * const contact, const char * const group)
|
_ui_group_removed(const char * const contact, const char * const group)
|
||||||
{
|
{
|
||||||
cons_show("%s removed from group %s", contact, group);
|
cons_show("%s removed from group %s", contact, group);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2938,119 +2937,6 @@ _ui_show_lines(ProfWin *window, const gchar** lines)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_ui_roster_contacts_by_presence(const char * const presence, char *title)
|
|
||||||
{
|
|
||||||
ProfWin *window = wins_get_console();
|
|
||||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
|
||||||
|
|
||||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
win_printline_nowrap(layout->subwin, title);
|
|
||||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
GSList *contacts = roster_get_contacts_by_presence(presence);
|
|
||||||
if (contacts) {
|
|
||||||
GSList *curr_contact = contacts;
|
|
||||||
while (curr_contact) {
|
|
||||||
PContact contact = curr_contact->data;
|
|
||||||
rosterwin_contact(contact);
|
|
||||||
curr_contact = g_slist_next(curr_contact);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_slist_free(contacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_ui_roster_contacts_by_group(char *group)
|
|
||||||
{
|
|
||||||
ProfWin *window = wins_get_console();
|
|
||||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
|
||||||
|
|
||||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
GString *title = g_string_new(" -");
|
|
||||||
g_string_append(title, group);
|
|
||||||
win_printline_nowrap(layout->subwin, title->str);
|
|
||||||
g_string_free(title, TRUE);
|
|
||||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
GSList *contacts = roster_get_group(group);
|
|
||||||
if (contacts) {
|
|
||||||
GSList *curr_contact = contacts;
|
|
||||||
while (curr_contact) {
|
|
||||||
PContact contact = curr_contact->data;
|
|
||||||
rosterwin_contact(contact);
|
|
||||||
curr_contact = g_slist_next(curr_contact);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_slist_free(contacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_ui_roster_contacts_by_no_group(void)
|
|
||||||
{
|
|
||||||
ProfWin *window = wins_get_console();
|
|
||||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
|
||||||
|
|
||||||
GSList *contacts = roster_get_nogroup();
|
|
||||||
if (contacts) {
|
|
||||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
win_printline_nowrap(layout->subwin, " -no group");
|
|
||||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
GSList *curr_contact = contacts;
|
|
||||||
while (curr_contact) {
|
|
||||||
PContact contact = curr_contact->data;
|
|
||||||
rosterwin_contact(contact);
|
|
||||||
curr_contact = g_slist_next(curr_contact);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_slist_free(contacts);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_ui_roster(void)
|
|
||||||
{
|
|
||||||
ProfWin *window = wins_get_console();
|
|
||||||
if (window) {
|
|
||||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
|
||||||
char *by = prefs_get_string(PREF_ROSTER_BY);
|
|
||||||
if (g_strcmp0(by, "presence") == 0) {
|
|
||||||
werase(layout->subwin);
|
|
||||||
_ui_roster_contacts_by_presence("chat", " -Available for chat");
|
|
||||||
_ui_roster_contacts_by_presence("online", " -Online");
|
|
||||||
_ui_roster_contacts_by_presence("away", " -Away");
|
|
||||||
_ui_roster_contacts_by_presence("xa", " -Extended Away");
|
|
||||||
_ui_roster_contacts_by_presence("dnd", " -Do not disturb");
|
|
||||||
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
|
||||||
_ui_roster_contacts_by_presence("offline", " -Offline");
|
|
||||||
}
|
|
||||||
} else if (g_strcmp0(by, "group") == 0) {
|
|
||||||
werase(layout->subwin);
|
|
||||||
GSList *groups = roster_get_groups();
|
|
||||||
GSList *curr_group = groups;
|
|
||||||
while (curr_group) {
|
|
||||||
_ui_roster_contacts_by_group(curr_group->data);
|
|
||||||
curr_group = g_slist_next(curr_group);
|
|
||||||
}
|
|
||||||
g_slist_free_full(groups, free);
|
|
||||||
_ui_roster_contacts_by_no_group();
|
|
||||||
} else {
|
|
||||||
GSList *contacts = roster_get_contacts();
|
|
||||||
if (contacts) {
|
|
||||||
werase(layout->subwin);
|
|
||||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
win_printline_nowrap(layout->subwin, " -Roster");
|
|
||||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
|
||||||
GSList *curr_contact = contacts;
|
|
||||||
while (curr_contact) {
|
|
||||||
PContact contact = curr_contact->data;
|
|
||||||
rosterwin_contact(contact);
|
|
||||||
curr_contact = g_slist_next(curr_contact);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_slist_free(contacts);
|
|
||||||
}
|
|
||||||
free(by);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ui_muc_roster(const char * const room)
|
_ui_muc_roster(const char * const room)
|
||||||
{
|
{
|
||||||
@ -3175,7 +3061,7 @@ _ui_show_roster(void)
|
|||||||
ProfWin *window = wins_get_console();
|
ProfWin *window = wins_get_console();
|
||||||
if (window && !win_has_active_subwin(window)) {
|
if (window && !win_has_active_subwin(window)) {
|
||||||
wins_show_subwin(window);
|
wins_show_subwin(window);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3498,7 +3384,6 @@ ui_init_module(void)
|
|||||||
ui_handle_room_role_list_error = _ui_handle_room_role_list_error;
|
ui_handle_room_role_list_error = _ui_handle_room_role_list_error;
|
||||||
ui_handle_room_role_list = _ui_handle_room_role_list;
|
ui_handle_room_role_list = _ui_handle_room_role_list;
|
||||||
ui_muc_roster = _ui_muc_roster;
|
ui_muc_roster = _ui_muc_roster;
|
||||||
ui_roster = _ui_roster;
|
|
||||||
ui_room_show_occupants = _ui_room_show_occupants;
|
ui_room_show_occupants = _ui_room_show_occupants;
|
||||||
ui_room_hide_occupants = _ui_room_hide_occupants;
|
ui_room_hide_occupants = _ui_room_hide_occupants;
|
||||||
ui_show_roster = _ui_show_roster;
|
ui_show_roster = _ui_show_roster;
|
||||||
|
@ -33,17 +33,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
|
#include "ui/ui.h"
|
||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
#include "ui/windows.h"
|
#include "ui/windows.h"
|
||||||
#include "config/preferences.h"
|
#include "config/preferences.h"
|
||||||
|
#include "roster_list.h"
|
||||||
|
|
||||||
void
|
static void
|
||||||
rosterwin_contact(PContact contact)
|
_rosterwin_contact(PContact contact)
|
||||||
{
|
{
|
||||||
if (p_contact_subscribed(contact)) {
|
if (p_contact_subscribed(contact)) {
|
||||||
ProfWin *window = wins_get_console();
|
ProfWin *console = wins_get_console();
|
||||||
const char *name = p_contact_name_or_jid(contact);
|
const char *name = p_contact_name_or_jid(contact);
|
||||||
const char *presence = p_contact_presence(contact);
|
const char *presence = p_contact_presence(contact);
|
||||||
|
|
||||||
@ -51,7 +54,7 @@ rosterwin_contact(PContact contact)
|
|||||||
(prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
|
(prefs_get_boolean(PREF_ROSTER_OFFLINE)))) {
|
||||||
theme_item_t presence_colour = theme_main_presence_attrs(presence);
|
theme_item_t presence_colour = theme_main_presence_attrs(presence);
|
||||||
|
|
||||||
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||||
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||||
|
|
||||||
wattron(layout->subwin, theme_attrs(presence_colour));
|
wattron(layout->subwin, theme_attrs(presence_colour));
|
||||||
@ -85,4 +88,128 @@ rosterwin_contact(PContact contact)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_rosterwin_contacts_by_presence(const char * const presence, char *title)
|
||||||
|
{
|
||||||
|
ProfWin *window = wins_get_console();
|
||||||
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)window->layout;
|
||||||
|
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||||
|
|
||||||
|
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
win_printline_nowrap(layout->subwin, title);
|
||||||
|
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
GSList *contacts = roster_get_contacts_by_presence(presence);
|
||||||
|
if (contacts) {
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_rosterwin_contact(contact);
|
||||||
|
curr_contact = g_slist_next(curr_contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_rosterwin_contacts_by_group(char *group)
|
||||||
|
{
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||||
|
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||||
|
|
||||||
|
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
GString *title = g_string_new(" -");
|
||||||
|
g_string_append(title, group);
|
||||||
|
win_printline_nowrap(layout->subwin, title->str);
|
||||||
|
g_string_free(title, TRUE);
|
||||||
|
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
GSList *contacts = roster_get_group(group);
|
||||||
|
if (contacts) {
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_rosterwin_contact(contact);
|
||||||
|
curr_contact = g_slist_next(curr_contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_rosterwin_contacts_by_no_group(void)
|
||||||
|
{
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||||
|
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||||
|
|
||||||
|
GSList *contacts = roster_get_nogroup();
|
||||||
|
if (contacts) {
|
||||||
|
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
win_printline_nowrap(layout->subwin, " -no group");
|
||||||
|
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_rosterwin_contact(contact);
|
||||||
|
curr_contact = g_slist_next(curr_contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_rosterwin_roster(void)
|
||||||
|
{
|
||||||
|
ProfWin *console = wins_get_console();
|
||||||
|
if (console) {
|
||||||
|
ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout;
|
||||||
|
assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK);
|
||||||
|
|
||||||
|
char *by = prefs_get_string(PREF_ROSTER_BY);
|
||||||
|
if (g_strcmp0(by, "presence") == 0) {
|
||||||
|
werase(layout->subwin);
|
||||||
|
_rosterwin_contacts_by_presence("chat", " -Available for chat");
|
||||||
|
_rosterwin_contacts_by_presence("online", " -Online");
|
||||||
|
_rosterwin_contacts_by_presence("away", " -Away");
|
||||||
|
_rosterwin_contacts_by_presence("xa", " -Extended Away");
|
||||||
|
_rosterwin_contacts_by_presence("dnd", " -Do not disturb");
|
||||||
|
if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) {
|
||||||
|
_rosterwin_contacts_by_presence("offline", " -Offline");
|
||||||
|
}
|
||||||
|
} else if (g_strcmp0(by, "group") == 0) {
|
||||||
|
werase(layout->subwin);
|
||||||
|
GSList *groups = roster_get_groups();
|
||||||
|
GSList *curr_group = groups;
|
||||||
|
while (curr_group) {
|
||||||
|
_rosterwin_contacts_by_group(curr_group->data);
|
||||||
|
curr_group = g_slist_next(curr_group);
|
||||||
|
}
|
||||||
|
g_slist_free_full(groups, free);
|
||||||
|
_rosterwin_contacts_by_no_group();
|
||||||
|
} else {
|
||||||
|
GSList *contacts = roster_get_contacts();
|
||||||
|
if (contacts) {
|
||||||
|
werase(layout->subwin);
|
||||||
|
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
win_printline_nowrap(layout->subwin, " -Roster");
|
||||||
|
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
|
||||||
|
GSList *curr_contact = contacts;
|
||||||
|
while (curr_contact) {
|
||||||
|
PContact contact = curr_contact->data;
|
||||||
|
_rosterwin_contact(contact);
|
||||||
|
curr_contact = g_slist_next(curr_contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_slist_free(contacts);
|
||||||
|
}
|
||||||
|
free(by);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
rosterwin_init_module(void)
|
||||||
|
{
|
||||||
|
rosterwin_roster = _rosterwin_roster;
|
||||||
}
|
}
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* rosterwin.h
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012 - 2014 James Booth <boothj5@gmail.com>
|
|
||||||
*
|
|
||||||
* This file is part of Profanity.
|
|
||||||
*
|
|
||||||
* Profanity is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Profanity is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Profanity. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* In addition, as a special exception, the copyright holders give permission to
|
|
||||||
* link the code of portions of this program with the OpenSSL library under
|
|
||||||
* certain conditions as described in each individual source file, and
|
|
||||||
* distribute linked combinations including the two.
|
|
||||||
*
|
|
||||||
* You must obey the GNU General Public License in all respects for all of the
|
|
||||||
* code used other than OpenSSL. If you modify file(s) with this exception, you
|
|
||||||
* may extend this exception to your version of the file(s), but you are not
|
|
||||||
* obligated to do so. If you do not wish to do so, delete this exception
|
|
||||||
* statement from your version. If you delete this exception statement from all
|
|
||||||
* source files in the program, then also delete it here.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void rosterwin_contact(PContact contact);
|
|
@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
void ui_init_module(void);
|
void ui_init_module(void);
|
||||||
void console_init_module(void);
|
void console_init_module(void);
|
||||||
|
void rosterwin_init_module(void);
|
||||||
void notifier_init_module(void);
|
void notifier_init_module(void);
|
||||||
|
|
||||||
// ui startup and control
|
// ui startup and control
|
||||||
@ -248,7 +249,6 @@ void (*ui_open_xmlconsole_win)(void);
|
|||||||
gboolean (*ui_win_has_unsaved_form)(int num);
|
gboolean (*ui_win_has_unsaved_form)(int num);
|
||||||
|
|
||||||
void (*ui_muc_roster)(const char * const room);
|
void (*ui_muc_roster)(const char * const room);
|
||||||
void (*ui_roster)(void);
|
|
||||||
|
|
||||||
// console window actions
|
// console window actions
|
||||||
void (*cons_show)(const char * const msg, ...);
|
void (*cons_show)(const char * const msg, ...);
|
||||||
@ -328,6 +328,9 @@ void (*cons_show_contact_online)(PContact contact, Resource *resource, GDateTime
|
|||||||
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
|
void (*cons_show_contact_offline)(PContact contact, char *resource, char *status);
|
||||||
void (*cons_theme_colours)(void);
|
void (*cons_theme_colours)(void);
|
||||||
|
|
||||||
|
// roster window
|
||||||
|
void (*rosterwin_roster)(void);
|
||||||
|
|
||||||
// desktop notifier actions
|
// desktop notifier actions
|
||||||
void (*notifier_uninit)(void);
|
void (*notifier_uninit)(void);
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ wins_resize_all(void)
|
|||||||
}
|
}
|
||||||
wresize(layout->super.win, PAD_SIZE, cols - subwin_cols);
|
wresize(layout->super.win, PAD_SIZE, cols - subwin_cols);
|
||||||
wresize(layout->subwin, PAD_SIZE, subwin_cols);
|
wresize(layout->subwin, PAD_SIZE, subwin_cols);
|
||||||
ui_roster();
|
rosterwin_roster();
|
||||||
} else {
|
} else {
|
||||||
wresize(layout->super.win, PAD_SIZE, cols);
|
wresize(layout->super.win, PAD_SIZE, cols);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ void console_doesnt_show_online_presence_when_set_none(void **state)
|
|||||||
{
|
{
|
||||||
mock_cons_show_contact_online();
|
mock_cons_show_contact_online();
|
||||||
stub_ui_chat_win_contact_online();
|
stub_ui_chat_win_contact_online();
|
||||||
stub_ui_roster();
|
stub_rosterwin_roster();
|
||||||
prefs_set_string(PREF_STATUSES_CONSOLE, "none");
|
prefs_set_string(PREF_STATUSES_CONSOLE, "none");
|
||||||
roster_init();
|
roster_init();
|
||||||
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
roster_add("test1@server", "bob", NULL, "both", FALSE);
|
||||||
|
@ -29,7 +29,7 @@ void _stub_cons_show(const char * const msg, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void _stub_ui_roster(void)
|
void _stub_rosterwin_roster(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,9 +206,9 @@ stub_ui_chat_win_contact_online(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stub_ui_roster(void)
|
stub_rosterwin_roster(void)
|
||||||
{
|
{
|
||||||
ui_roster = _stub_ui_roster;
|
rosterwin_roster = _stub_rosterwin_roster;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "ui/window.h"
|
#include "ui/window.h"
|
||||||
|
|
||||||
void stub_cons_show(void);
|
void stub_cons_show(void);
|
||||||
void stub_ui_roster(void);
|
void stub_rosterwin_roster(void);
|
||||||
|
|
||||||
void mock_cons_show(void);
|
void mock_cons_show(void);
|
||||||
void expect_cons_show(char *output);
|
void expect_cons_show(char *output);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user