1
0
Fork 0

Roster private chat preferences

This commit is contained in:
James Booth 2016-01-24 02:28:22 +00:00
parent 7cacee8781
commit 2a8da892aa
7 changed files with 206 additions and 47 deletions

View File

@ -283,10 +283,12 @@ static struct cmd_t command_defs[] =
"/roster by group|presence|none",
"/roster order name|presence",
"/roster unread before|after|off",
"/roster room char <char>|none",
"/roster room position first|last",
"/roster room order name|unread",
"/roster room unread before|after|off",
"/roster private room|group|off",
"/roster private char <char>|none",
"/roster header char <char>|none",
"/roster presence indent <indent>",
"/roster contact char <char>|none",
@ -334,6 +336,8 @@ static struct cmd_t command_defs[] =
{ "unread before", "Show unread message count before contact in roster." },
{ "unread after", "Show unread message count after contact in roster." },
{ "unread off", "Do not show unread message count for contacts in roster." },
{ "room char <char>", "Prefix roster rooms with specified character." },
{ "room char none", "Remove roster room character prefix." },
{ "room position first", "Show rooms first in roster." },
{ "room position last", "Show rooms last in roster." },
{ "room order name", "Order roster rooms by name." },
@ -341,9 +345,11 @@ static struct cmd_t command_defs[] =
{ "room unread before", "Show unread message count before room in roster." },
{ "room unread after", "Show unread message count after room in roster." },
{ "room unread off", "Do not show unread message count for rooms in roster." },
{ "room private room", "Show room private chats below the room in the roster." },
{ "room private group", "Show room private chats as a separate roster group." },
{ "room private off", "Do not show room private chats in the roster." },
{ "private room", "Show room private chats below the room in the roster." },
{ "private group", "Show room private chats as a separate roster group." },
{ "private off", "Do not show room private chats in the roster." },
{ "private char <char>", "Prefix roster private room chats with specified character." },
{ "private char none", "Remove roster private room chat character prefix." },
{ "header char <char>", "Prefix roster headers with specified character." },
{ "header char none", "Remove roster header character prefix." },
{ "contact char <char>", "Prefix roster contacts with specified character." },
@ -2209,6 +2215,7 @@ cmd_init(void)
autocomplete_add(roster_private_ac, "room");
autocomplete_add(roster_private_ac, "group");
autocomplete_add(roster_private_ac, "off");
autocomplete_add(roster_private_ac, "char");
roster_header_ac = autocomplete_new();
autocomplete_add(roster_header_ac, "char");
@ -2254,6 +2261,7 @@ cmd_init(void)
autocomplete_add(roster_unread_ac, "off");
roster_room_ac = autocomplete_new();
autocomplete_add(roster_room_ac, "char");
autocomplete_add(roster_room_ac, "position");
autocomplete_add(roster_room_ac, "order");
autocomplete_add(roster_room_ac, "unread");
@ -3156,6 +3164,14 @@ _roster_autocomplete(ProfWin *window, const char *const input)
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster room char", roster_char_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster private char", roster_char_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster resource char", roster_char_ac, TRUE);
if (result) {
return result;

View File

@ -2409,7 +2409,20 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
}
} else if (g_strcmp0(args[0], "private") == 0) {
if (g_strcmp0(args[1], "room") == 0) {
if (g_strcmp0(args[1], "char") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else if (g_strcmp0(args[2], "none") == 0) {
prefs_clear_roster_private_char();
cons_show("Roster private room chat char removed.");
rosterwin_roster();
} else {
prefs_set_roster_private_char(args[2][0]);
cons_show("Roster private room chat char set to %c.", args[2][0]);
rosterwin_roster();
}
return TRUE;
} else if (g_strcmp0(args[1], "room") == 0) {
cons_show("Showing room private chats under room.");
prefs_set_string(PREF_ROSTER_PRIVATE, "room");
if (conn_status == JABBER_CONNECTED) {
@ -2436,7 +2449,20 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
}
} else if (g_strcmp0(args[0], "room") == 0) {
if (g_strcmp0(args[1], "position") == 0) {
if (g_strcmp0(args[1], "char") == 0) {
if (!args[2]) {
cons_bad_cmd_usage(command);
} else if (g_strcmp0(args[2], "none") == 0) {
prefs_clear_roster_room_char();
cons_show("Roster room char removed.");
rosterwin_roster();
} else {
prefs_set_roster_room_char(args[2][0]);
cons_show("Roster room char set to %c.", args[2][0]);
rosterwin_roster();
}
return TRUE;
} else if (g_strcmp0(args[1], "position") == 0) {
if (g_strcmp0(args[2], "first") == 0) {
cons_show("Showing rooms first in roster.");
prefs_set_string(PREF_ROSTER_ROOMS_POS, "first");

View File

@ -755,6 +755,80 @@ prefs_clear_roster_resource_char(void)
_save_prefs();
}
char
prefs_get_roster_private_char(void)
{
char result = 0;
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.private.char", NULL);
if (!resultstr) {
result = 0;
} else {
result = resultstr[0];
}
free(resultstr);
return result;
}
void
prefs_set_roster_private_char(char ch)
{
char str[2];
str[0] = ch;
str[1] = '\0';
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.private.char", str);
_save_prefs();
}
void
prefs_clear_roster_private_char(void)
{
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.private.char", NULL);
_save_prefs();
}
char
prefs_get_roster_room_char(void)
{
char result = 0;
char *resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL);
if (!resultstr) {
result = 0;
} else {
result = resultstr[0];
}
free(resultstr);
return result;
}
void
prefs_set_roster_room_char(char ch)
{
char str[2];
str[0] = ch;
str[1] = '\0';
g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.rooms.char", str);
_save_prefs();
}
void
prefs_clear_roster_room_char(void)
{
g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.rooms.char", NULL);
_save_prefs();
}
gint
prefs_get_roster_contact_indent(void)
{

View File

@ -192,6 +192,12 @@ void prefs_clear_roster_contact_char(void);
char prefs_get_roster_resource_char(void);
void prefs_set_roster_resource_char(char ch);
void prefs_clear_roster_resource_char(void);
char prefs_get_roster_private_char(void);
void prefs_set_roster_private_char(char ch);
void prefs_clear_roster_private_char(void);
char prefs_get_roster_room_char(void);
void prefs_set_roster_room_char(char ch);
void prefs_clear_roster_room_char(void);
gint prefs_get_roster_contact_indent(void);
void prefs_set_roster_contact_indent(gint value);

View File

@ -373,29 +373,10 @@ _load_preferences(void)
_set_boolean_preference("splash", PREF_SPLASH);
_set_boolean_preference("wrap", PREF_WRAP);
_set_boolean_preference("wins.autotidy", PREF_WINS_AUTO_TIDY);
_set_string_preference("time.console", PREF_TIME_CONSOLE);
_set_string_preference("time.chat", PREF_TIME_CHAT);
_set_string_preference("time.muc", PREF_TIME_MUC);
_set_string_preference("time.mucconfig", PREF_TIME_MUCCONFIG);
_set_string_preference("time.private", PREF_TIME_PRIVATE);
_set_string_preference("time.xmlconsole", PREF_TIME_XMLCONSOLE);
_set_string_preference("time.statusbar", PREF_TIME_STATUSBAR);
_set_string_preference("time.lastactivity", PREF_TIME_LASTACTIVITY);
_set_boolean_preference("resource.title", PREF_RESOURCE_TITLE);
_set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE);
_set_string_preference("statuses.console", PREF_STATUSES_CONSOLE);
_set_string_preference("statuses.chat", PREF_STATUSES_CHAT);
_set_string_preference("statuses.muc", PREF_STATUSES_MUC);
_set_boolean_preference("occupants", PREF_OCCUPANTS);
_set_boolean_preference("occupants.jid", PREF_OCCUPANTS_JID);
if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) {
gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL);
prefs_set_occupants_size(occupants_size);
}
_set_boolean_preference("roster", PREF_ROSTER);
_set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
_set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
@ -404,21 +385,46 @@ _load_preferences(void)
_set_boolean_preference("roster.status", PREF_ROSTER_STATUS);
_set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY);
_set_boolean_preference("roster.wrap", PREF_ROSTER_WRAP);
_set_string_preference("roster.by", PREF_ROSTER_BY);
_set_string_preference("roster.order", PREF_ROSTER_ORDER);
_set_string_preference("roster.unread", PREF_ROSTER_UNREAD);
_set_boolean_preference("roster.count", PREF_ROSTER_COUNT);
_set_boolean_preference("roster.priority", PREF_ROSTER_PRIORITY);
_set_boolean_preference("roster.contacts", PREF_ROSTER_CONTACTS);
_set_boolean_preference("roster.rooms", PREF_ROSTER_ROOMS);
_set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
_set_boolean_preference("presence", PREF_PRESENCE);
_set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("enc.warn", PREF_ENC_WARN);
_set_boolean_preference("tls.show", PREF_TLS_SHOW);
_set_string_preference("time.console", PREF_TIME_CONSOLE);
_set_string_preference("time.chat", PREF_TIME_CHAT);
_set_string_preference("time.muc", PREF_TIME_MUC);
_set_string_preference("time.mucconfig", PREF_TIME_MUCCONFIG);
_set_string_preference("time.private", PREF_TIME_PRIVATE);
_set_string_preference("time.xmlconsole", PREF_TIME_XMLCONSOLE);
_set_string_preference("time.statusbar", PREF_TIME_STATUSBAR);
_set_string_preference("time.lastactivity", PREF_TIME_LASTACTIVITY);
_set_string_preference("statuses.console", PREF_STATUSES_CONSOLE);
_set_string_preference("statuses.chat", PREF_STATUSES_CHAT);
_set_string_preference("statuses.muc", PREF_STATUSES_MUC);
_set_string_preference("console.muc", PREF_CONSOLE_MUC);
_set_string_preference("roster.by", PREF_ROSTER_BY);
_set_string_preference("roster.order", PREF_ROSTER_ORDER);
_set_string_preference("roster.unread", PREF_ROSTER_UNREAD);
_set_string_preference("roster.rooms.order", PREF_ROSTER_ROOMS_ORDER);
_set_string_preference("roster.rooms.unread", PREF_ROSTER_ROOMS_UNREAD);
_set_string_preference("roster.rooms.pos", PREF_ROSTER_ROOMS_POS);
_set_string_preference("roster.private", PREF_ROSTER_PRIVATE);
if (g_key_file_has_key(theme, "ui", "occupants.size", NULL)) {
gint occupants_size = g_key_file_get_integer(theme, "ui", "occupants.size", NULL);
prefs_set_occupants_size(occupants_size);
}
if (g_key_file_has_key(theme, "ui", "roster.size", NULL)) {
gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL);
prefs_set_roster_size(roster_size);
}
if (g_key_file_has_key(theme, "ui", "roster.header.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL);
if (ch && strlen(ch) > 0) {
@ -428,6 +434,7 @@ _load_preferences(void)
} else {
prefs_clear_roster_header_char();
}
if (g_key_file_has_key(theme, "ui", "roster.contact.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
if (ch && strlen(ch) > 0) {
@ -437,6 +444,7 @@ _load_preferences(void)
} else {
prefs_clear_roster_contact_char();
}
if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
if (ch && strlen(ch) > 0) {
@ -446,27 +454,42 @@ _load_preferences(void)
} else {
prefs_clear_roster_resource_char();
}
if (g_key_file_has_key(theme, "ui", "roster.rooms.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.rooms.char", NULL);
if (ch && strlen(ch) > 0) {
prefs_set_roster_room_char(ch[0]);
g_free(ch);
}
} else {
prefs_clear_roster_room_char();
}
if (g_key_file_has_key(theme, "ui", "roster.private.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "roster.private.char", NULL);
if (ch && strlen(ch) > 0) {
prefs_set_roster_private_char(ch[0]);
g_free(ch);
}
} else {
prefs_clear_roster_private_char();
}
if (g_key_file_has_key(theme, "ui", "roster.contact.indent", NULL)) {
gint contact_indent = g_key_file_get_integer(theme, "ui", "roster.contact.indent", NULL);
prefs_set_roster_contact_indent(contact_indent);
}
if (g_key_file_has_key(theme, "ui", "roster.resource.indent", NULL)) {
gint resource_indent = g_key_file_get_integer(theme, "ui", "roster.resource.indent", NULL);
prefs_set_roster_resource_indent(resource_indent);
}
if (g_key_file_has_key(theme, "ui", "roster.presence.indent", NULL)) {
gint presence_indent = g_key_file_get_integer(theme, "ui", "roster.presence.indent", NULL);
prefs_set_roster_presence_indent(presence_indent);
}
_set_boolean_preference("privileges", PREF_MUC_PRIVILEGES);
_set_boolean_preference("presence", PREF_PRESENCE);
_set_boolean_preference("intype", PREF_INTYPE);
_set_boolean_preference("enc.warn", PREF_ENC_WARN);
_set_boolean_preference("tls.show", PREF_TLS_SHOW);
if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);
if (ch && strlen(ch) > 0) {
@ -474,6 +497,7 @@ _load_preferences(void)
g_free(ch);
}
}
if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL);
if (ch && strlen(ch) > 0) {
@ -481,8 +505,6 @@ _load_preferences(void)
g_free(ch);
}
}
_set_string_preference("console.muc", PREF_CONSOLE_MUC);
}
static gchar*

View File

@ -1277,6 +1277,24 @@ cons_roster_setting(void)
else
cons_show("Roster contact char (/roster) : none");
char resource_ch = prefs_get_roster_resource_char();
if (resource_ch)
cons_show("Roster resource char (/roster) : %c", resource_ch);
else
cons_show("Roster resource char (/roster) : none");
char room_ch = prefs_get_roster_room_char();
if (room_ch)
cons_show("Roster room char (/roster) : %c", room_ch);
else
cons_show("Roster room char (/roster) : none");
char private_ch = prefs_get_roster_private_char();
if (private_ch)
cons_show("Roster private char (/roster) : %c", private_ch);
else
cons_show("Roster private char (/roster) : none");
gint contact_indent = prefs_get_roster_contact_indent();
cons_show("Roster contact indent (/roster) : %d", contact_indent);
@ -1285,12 +1303,6 @@ cons_roster_setting(void)
else
cons_show("Roster resource (/roster) : hide");
char resource_ch = prefs_get_roster_resource_char();
if (resource_ch)
cons_show("Roster resource char (/roster) : %c", resource_ch);
else
cons_show("Roster resource char (/roster) : none");
gint resource_indent = prefs_get_roster_resource_indent();
cons_show("Roster resource indent (/roster) : %d", resource_indent);

View File

@ -494,7 +494,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
indent--;
}
}
char ch = prefs_get_roster_contact_char();
char ch = prefs_get_roster_room_char();
if (ch) {
g_string_append_printf(msg, "%c", ch);
}
@ -549,14 +549,12 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
}
}
// TODO add preference
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);
}
// TODO add preference
ch = '/';
ch = prefs_get_roster_private_char();
if (ch) {
g_string_append_printf(privmsg, "%c", ch);
}
@ -652,6 +650,11 @@ _rosterwin_private_chats(ProfLayoutSplit *layout)
g_string_append_printf(privmsg, "(%d) ", privwin->unread);
}
ch = prefs_get_roster_private_char();
if (ch) {
g_string_append_printf(privmsg, "%c", ch);
}
g_string_append(privmsg, privwin->fulljid);
if ((g_strcmp0(unreadpos, "after") == 0) && privwin->unread > 0) {