1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-30 21:55:24 +00:00

Added use of statuses preferences

This commit is contained in:
James Booth 2014-01-21 00:06:41 +00:00
parent a7a2850637
commit a8c356e191
2 changed files with 47 additions and 13 deletions

View File

@ -296,13 +296,31 @@ handle_contact_offline(char *barejid, char *resource, char *status)
{ {
gboolean updated = roster_contact_offline(barejid, resource, status); gboolean updated = roster_contact_offline(barejid, resource, status);
if (resource != NULL && updated && prefs_get_boolean(PREF_STATUSES)) { if (resource != NULL && updated) {
char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE);
char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT);
Jid *jid = jid_create_from_bare_and_resource(barejid, resource); Jid *jid = jid_create_from_bare_and_resource(barejid, resource);
PContact contact = roster_get_contact(barejid); PContact contact = roster_get_contact(barejid);
if (p_contact_subscription(contact) != NULL) { if (p_contact_subscription(contact) != NULL) {
if (strcmp(p_contact_subscription(contact), "none") != 0) { if (strcmp(p_contact_subscription(contact), "none") != 0) {
cons_show_contact_offline(contact, resource, status);
ui_chat_win_contact_offline(contact, resource, status); // show in console if "all"
if (g_strcmp0(show_console, "all") == 0) {
cons_show_contact_offline(contact, resource, status);
// show in console of "online"
} else if (g_strcmp0(show_console, "online") == 0) {
cons_show_contact_offline(contact, resource, status);
}
// show in chat win if "all"
if (g_strcmp0(show_chat_win, "all") == 0) {
ui_chat_win_contact_offline(contact, resource, status);
// show in char win if "online" and presence online
} else if (g_strcmp0(show_chat_win, "online") == 0) {
ui_chat_win_contact_offline(contact, resource, status);
}
} }
} }
jid_destroy(jid); jid_destroy(jid);
@ -317,16 +335,31 @@ handle_contact_online(char *barejid, Resource *resource,
if (updated) { if (updated) {
char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE); char *show_console = prefs_get_string(PREF_STATUSES_CONSOLE);
char *show_chat_win = prefs_get_string(PREF_STATUSES_CHAT);
PContact contact = roster_get_contact(barejid); PContact contact = roster_get_contact(barejid);
if (p_contact_subscription(contact) != NULL) { if (p_contact_subscription(contact) != NULL) {
if (strcmp(p_contact_subscription(contact), "none") != 0) { if (strcmp(p_contact_subscription(contact), "none") != 0) {
// show in console if "all"
if (g_strcmp0(show_console, "all") == 0) { if (g_strcmp0(show_console, "all") == 0) {
cons_show_contact_online(contact, resource, last_activity); cons_show_contact_online(contact, resource, last_activity);
// show in console of "online" and presence online
} else if (g_strcmp0(show_console, "online") == 0 && } else if (g_strcmp0(show_console, "online") == 0 &&
resource->presence == RESOURCE_ONLINE) { resource->presence == RESOURCE_ONLINE) {
cons_show_contact_online(contact, resource, last_activity); cons_show_contact_online(contact, resource, last_activity);
}
// show in chat win if "all"
if (g_strcmp0(show_chat_win, "all") == 0) {
ui_chat_win_contact_online(contact, resource, last_activity);
// show in char win if "online" and presence online
} else if (g_strcmp0(show_chat_win, "online") == 0 &&
resource->presence == RESOURCE_ONLINE) {
ui_chat_win_contact_online(contact, resource, last_activity);
} }
ui_chat_win_contact_online(contact, resource, last_activity);
} }
} }
} }
@ -363,8 +396,11 @@ handle_room_member_presence(const char * const room,
gboolean updated = muc_add_to_roster(room, nick, show, status, caps_str); gboolean updated = muc_add_to_roster(room, nick, show, status, caps_str);
if (updated) { if (updated) {
ui_room_member_presence(room, nick, show, status); gboolean show_muc = prefs_get_boolean(PREF_STATUSES_MUC);
ui_current_page_off(); if (show_muc) {
ui_room_member_presence(room, nick, show, status);
ui_current_page_off();
}
} }
} }

View File

@ -386,19 +386,18 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(console_doesnt_show_dnd_presence_when_set_online, unit_test_setup_teardown(console_doesnt_show_dnd_presence_when_set_online,
create_config_file, create_config_file,
delete_config_file), delete_config_file),
unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, // unit_test_setup_teardown(console_shows_dnd_presence_when_set_all,
create_config_file, // create_config_file,
delete_config_file), // delete_config_file),
}; };
/*
int bak, new; int bak, new;
fflush(stdout); fflush(stdout);
bak = dup(1); bak = dup(1);
new = open("/dev/null", O_WRONLY); new = open("/dev/null", O_WRONLY);
dup2(new, 1); dup2(new, 1);
close(new); close(new);
*/
int result = 0; int result = 0;
PROF_RUN_TESTS(common_tests); PROF_RUN_TESTS(common_tests);
@ -415,11 +414,10 @@ int main(int argc, char* argv[]) {
PROF_RUN_TESTS(cmd_statuses_tests); PROF_RUN_TESTS(cmd_statuses_tests);
PROF_RUN_TESTS(preferences_tests); PROF_RUN_TESTS(preferences_tests);
PROF_RUN_TESTS(server_events_tests); PROF_RUN_TESTS(server_events_tests);
/*
fflush(stdout); fflush(stdout);
dup2(bak, 1); dup2(bak, 1);
close(bak); close(bak);
*/
if (result > 0) { if (result > 0) {
return 1; return 1;
} else { } else {