1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-01-24 03:03:22 +00:00
commit f40928f34f
13 changed files with 445 additions and 43 deletions

View File

@ -283,9 +283,12 @@ static struct cmd_t command_defs[] =
"/roster by group|presence|none", "/roster by group|presence|none",
"/roster order name|presence", "/roster order name|presence",
"/roster unread before|after|off", "/roster unread before|after|off",
"/roster room char <char>|none",
"/roster room position first|last", "/roster room position first|last",
"/roster room order name|unread", "/roster room order name|unread",
"/roster room unread before|after|off", "/roster room unread before|after|off",
"/roster private room|group|off",
"/roster private char <char>|none",
"/roster header char <char>|none", "/roster header char <char>|none",
"/roster presence indent <indent>", "/roster presence indent <indent>",
"/roster contact char <char>|none", "/roster contact char <char>|none",
@ -333,6 +336,8 @@ static struct cmd_t command_defs[] =
{ "unread before", "Show unread message count before contact in roster." }, { "unread before", "Show unread message count before contact in roster." },
{ "unread after", "Show unread message count after 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." }, { "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 first", "Show rooms first in roster." },
{ "room position last", "Show rooms last in roster." }, { "room position last", "Show rooms last in roster." },
{ "room order name", "Order roster rooms by name." }, { "room order name", "Order roster rooms by name." },
@ -340,6 +345,11 @@ static struct cmd_t command_defs[] =
{ "room unread before", "Show unread message count before room in roster." }, { "room unread before", "Show unread message count before room in roster." },
{ "room unread after", "Show unread message count after 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 unread off", "Do not show unread message count for rooms in 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 <char>", "Prefix roster headers with specified character." },
{ "header char none", "Remove roster header character prefix." }, { "header char none", "Remove roster header character prefix." },
{ "contact char <char>", "Prefix roster contacts with specified character." }, { "contact char <char>", "Prefix roster contacts with specified character." },
@ -1931,6 +1941,7 @@ static Autocomplete roster_room_ac;
static Autocomplete roster_room_position_ac; static Autocomplete roster_room_position_ac;
static Autocomplete roster_room_order_ac; static Autocomplete roster_room_order_ac;
static Autocomplete roster_unread_ac; static Autocomplete roster_unread_ac;
static Autocomplete roster_private_ac;
static Autocomplete group_ac; static Autocomplete group_ac;
static Autocomplete bookmark_ac; static Autocomplete bookmark_ac;
static Autocomplete bookmark_property_ac; static Autocomplete bookmark_property_ac;
@ -2198,6 +2209,13 @@ cmd_init(void)
autocomplete_add(roster_ac, "contact"); autocomplete_add(roster_ac, "contact");
autocomplete_add(roster_ac, "resource"); autocomplete_add(roster_ac, "resource");
autocomplete_add(roster_ac, "presence"); autocomplete_add(roster_ac, "presence");
autocomplete_add(roster_ac, "private");
roster_private_ac = autocomplete_new();
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(); roster_header_ac = autocomplete_new();
autocomplete_add(roster_header_ac, "char"); autocomplete_add(roster_header_ac, "char");
@ -2243,6 +2261,7 @@ cmd_init(void)
autocomplete_add(roster_unread_ac, "off"); autocomplete_add(roster_unread_ac, "off");
roster_room_ac = autocomplete_new(); roster_room_ac = autocomplete_new();
autocomplete_add(roster_room_ac, "char");
autocomplete_add(roster_room_ac, "position"); autocomplete_add(roster_room_ac, "position");
autocomplete_add(roster_room_ac, "order"); autocomplete_add(roster_room_ac, "order");
autocomplete_add(roster_room_ac, "unread"); autocomplete_add(roster_room_ac, "unread");
@ -2532,6 +2551,7 @@ cmd_uninit(void)
autocomplete_free(roster_room_position_ac); autocomplete_free(roster_room_position_ac);
autocomplete_free(roster_room_order_ac); autocomplete_free(roster_room_order_ac);
autocomplete_free(roster_remove_all_ac); autocomplete_free(roster_remove_all_ac);
autocomplete_free(roster_private_ac);
autocomplete_free(group_ac); autocomplete_free(group_ac);
autocomplete_free(bookmark_ac); autocomplete_free(bookmark_ac);
autocomplete_free(bookmark_property_ac); autocomplete_free(bookmark_property_ac);
@ -2744,6 +2764,7 @@ cmd_reset_autocomplete(ProfWin *window)
autocomplete_reset(roster_room_position_ac); autocomplete_reset(roster_room_position_ac);
autocomplete_reset(roster_room_order_ac); autocomplete_reset(roster_room_order_ac);
autocomplete_reset(roster_remove_all_ac); autocomplete_reset(roster_remove_all_ac);
autocomplete_reset(roster_private_ac);
autocomplete_reset(group_ac); autocomplete_reset(group_ac);
autocomplete_reset(titlebar_ac); autocomplete_reset(titlebar_ac);
autocomplete_reset(bookmark_ac); autocomplete_reset(bookmark_ac);
@ -3143,6 +3164,14 @@ _roster_autocomplete(ProfWin *window, const char *const input)
if (result) { if (result) {
return 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); result = autocomplete_param_with_ac(input, "/roster resource char", roster_char_ac, TRUE);
if (result) { if (result) {
return result; return result;
@ -3228,6 +3257,10 @@ _roster_autocomplete(ProfWin *window, const char *const input)
if (result) { if (result) {
return result; return result;
} }
result = autocomplete_param_with_ac(input, "/roster private", roster_private_ac, TRUE);
if (result) {
return result;
}
result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE); result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE);
if (result) { if (result) {
return result; return result;

View File

@ -2408,8 +2408,61 @@ cmd_roster(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
} else if (g_strcmp0(args[0], "private") == 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) {
rosterwin_roster();
}
return TRUE;
} else if (g_strcmp0(args[1], "group") == 0) {
cons_show("Showing room private chats as roster group.");
prefs_set_string(PREF_ROSTER_PRIVATE, "group");
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else if (g_strcmp0(args[1], "off") == 0) {
cons_show("Hiding room private chats in roster.");
prefs_set_string(PREF_ROSTER_PRIVATE, "off");
if (conn_status == JABBER_CONNECTED) {
rosterwin_roster();
}
return TRUE;
} else {
cons_bad_cmd_usage(command);
return TRUE;
}
} else if (g_strcmp0(args[0], "room") == 0) { } 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) { if (g_strcmp0(args[2], "first") == 0) {
cons_show("Showing rooms first in roster."); cons_show("Showing rooms first in roster.");
prefs_set_string(PREF_ROSTER_ROOMS_POS, "first"); prefs_set_string(PREF_ROSTER_ROOMS_POS, "first");

View File

@ -755,6 +755,80 @@ prefs_clear_roster_resource_char(void)
_save_prefs(); _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 gint
prefs_get_roster_contact_indent(void) prefs_get_roster_contact_indent(void)
{ {
@ -1051,6 +1125,7 @@ _get_group(preference_t pref)
case PREF_ROSTER_ROOMS_POS: case PREF_ROSTER_ROOMS_POS:
case PREF_ROSTER_ROOMS_ORDER: case PREF_ROSTER_ROOMS_ORDER:
case PREF_ROSTER_ROOMS_UNREAD: case PREF_ROSTER_ROOMS_UNREAD:
case PREF_ROSTER_PRIVATE:
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:
case PREF_ENC_WARN: case PREF_ENC_WARN:
@ -1257,6 +1332,8 @@ _get_key(preference_t pref)
return "roster.rooms.order"; return "roster.rooms.order";
case PREF_ROSTER_ROOMS_UNREAD: case PREF_ROSTER_ROOMS_UNREAD:
return "roster.rooms.unread"; return "roster.rooms.unread";
case PREF_ROSTER_PRIVATE:
return "roster.private";
case PREF_RESOURCE_TITLE: case PREF_RESOURCE_TITLE:
return "resource.title"; return "resource.title";
case PREF_RESOURCE_MESSAGE: case PREF_RESOURCE_MESSAGE:
@ -1353,6 +1430,8 @@ _get_default_string(preference_t pref)
return "name"; return "name";
case PREF_ROSTER_ROOMS_UNREAD: case PREF_ROSTER_ROOMS_UNREAD:
return "after"; return "after";
case PREF_ROSTER_PRIVATE:
return "room";
case PREF_TIME_CONSOLE: case PREF_TIME_CONSOLE:
return "%H:%M:%S"; return "%H:%M:%S";
case PREF_TIME_CHAT: case PREF_TIME_CHAT:

View File

@ -79,6 +79,7 @@ typedef enum {
PREF_ROSTER_ROOMS_POS, PREF_ROSTER_ROOMS_POS,
PREF_ROSTER_ROOMS_ORDER, PREF_ROSTER_ROOMS_ORDER,
PREF_ROSTER_ROOMS_UNREAD, PREF_ROSTER_ROOMS_UNREAD,
PREF_ROSTER_PRIVATE,
PREF_MUC_PRIVILEGES, PREF_MUC_PRIVILEGES,
PREF_PRESENCE, PREF_PRESENCE,
PREF_WRAP, PREF_WRAP,
@ -191,6 +192,12 @@ void prefs_clear_roster_contact_char(void);
char prefs_get_roster_resource_char(void); char prefs_get_roster_resource_char(void);
void prefs_set_roster_resource_char(char ch); void prefs_set_roster_resource_char(char ch);
void prefs_clear_roster_resource_char(void); 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); gint prefs_get_roster_contact_indent(void);
void prefs_set_roster_contact_indent(gint value); 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("splash", PREF_SPLASH);
_set_boolean_preference("wrap", PREF_WRAP); _set_boolean_preference("wrap", PREF_WRAP);
_set_boolean_preference("wins.autotidy", PREF_WINS_AUTO_TIDY); _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.title", PREF_RESOURCE_TITLE);
_set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE); _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", PREF_OCCUPANTS);
_set_boolean_preference("occupants.jid", PREF_OCCUPANTS_JID); _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", PREF_ROSTER);
_set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE); _set_boolean_preference("roster.offline", PREF_ROSTER_OFFLINE);
_set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE); _set_boolean_preference("roster.resource", PREF_ROSTER_RESOURCE);
@ -404,20 +385,46 @@ _load_preferences(void)
_set_boolean_preference("roster.status", PREF_ROSTER_STATUS); _set_boolean_preference("roster.status", PREF_ROSTER_STATUS);
_set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY); _set_boolean_preference("roster.empty", PREF_ROSTER_EMPTY);
_set_boolean_preference("roster.wrap", PREF_ROSTER_WRAP); _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.count", PREF_ROSTER_COUNT);
_set_boolean_preference("roster.priority", PREF_ROSTER_PRIORITY); _set_boolean_preference("roster.priority", PREF_ROSTER_PRIORITY);
_set_boolean_preference("roster.contacts", PREF_ROSTER_CONTACTS); _set_boolean_preference("roster.contacts", PREF_ROSTER_CONTACTS);
_set_boolean_preference("roster.rooms", PREF_ROSTER_ROOMS); _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.order", PREF_ROSTER_ROOMS_ORDER);
_set_string_preference("roster.rooms.unread", PREF_ROSTER_ROOMS_UNREAD); _set_string_preference("roster.rooms.unread", PREF_ROSTER_ROOMS_UNREAD);
_set_string_preference("roster.rooms.pos", PREF_ROSTER_ROOMS_POS); _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)) { if (g_key_file_has_key(theme, "ui", "roster.size", NULL)) {
gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL); gint roster_size = g_key_file_get_integer(theme, "ui", "roster.size", NULL);
prefs_set_roster_size(roster_size); prefs_set_roster_size(roster_size);
} }
if (g_key_file_has_key(theme, "ui", "roster.header.char", NULL)) { 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); gchar *ch = g_key_file_get_string(theme, "ui", "roster.header.char", NULL);
if (ch && strlen(ch) > 0) { if (ch && strlen(ch) > 0) {
@ -427,6 +434,7 @@ _load_preferences(void)
} else { } else {
prefs_clear_roster_header_char(); prefs_clear_roster_header_char();
} }
if (g_key_file_has_key(theme, "ui", "roster.contact.char", NULL)) { 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); gchar *ch = g_key_file_get_string(theme, "ui", "roster.contact.char", NULL);
if (ch && strlen(ch) > 0) { if (ch && strlen(ch) > 0) {
@ -436,6 +444,7 @@ _load_preferences(void)
} else { } else {
prefs_clear_roster_contact_char(); prefs_clear_roster_contact_char();
} }
if (g_key_file_has_key(theme, "ui", "roster.resource.char", NULL)) { 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); gchar *ch = g_key_file_get_string(theme, "ui", "roster.resource.char", NULL);
if (ch && strlen(ch) > 0) { if (ch && strlen(ch) > 0) {
@ -445,27 +454,42 @@ _load_preferences(void)
} else { } else {
prefs_clear_roster_resource_char(); 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)) { 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); gint contact_indent = g_key_file_get_integer(theme, "ui", "roster.contact.indent", NULL);
prefs_set_roster_contact_indent(contact_indent); prefs_set_roster_contact_indent(contact_indent);
} }
if (g_key_file_has_key(theme, "ui", "roster.resource.indent", NULL)) { 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); gint resource_indent = g_key_file_get_integer(theme, "ui", "roster.resource.indent", NULL);
prefs_set_roster_resource_indent(resource_indent); prefs_set_roster_resource_indent(resource_indent);
} }
if (g_key_file_has_key(theme, "ui", "roster.presence.indent", NULL)) { 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); gint presence_indent = g_key_file_get_integer(theme, "ui", "roster.presence.indent", NULL);
prefs_set_roster_presence_indent(presence_indent); 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)) { if (g_key_file_has_key(theme, "ui", "otr.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL); gchar *ch = g_key_file_get_string(theme, "ui", "otr.char", NULL);
if (ch && strlen(ch) > 0) { if (ch && strlen(ch) > 0) {
@ -473,6 +497,7 @@ _load_preferences(void)
g_free(ch); g_free(ch);
} }
} }
if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) { if (g_key_file_has_key(theme, "ui", "pgp.char", NULL)) {
gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL); gchar *ch = g_key_file_get_string(theme, "ui", "pgp.char", NULL);
if (ch && strlen(ch) > 0) { if (ch && strlen(ch) > 0) {
@ -480,8 +505,6 @@ _load_preferences(void)
g_free(ch); g_free(ch);
} }
} }
_set_string_preference("console.muc", PREF_CONSOLE_MUC);
} }
static gchar* static gchar*

View File

@ -315,6 +315,7 @@ sv_ev_incoming_private_message(const char *const fulljid, char *message)
privatewin = (ProfPrivateWin*)window; privatewin = (ProfPrivateWin*)window;
} }
privwin_incoming_msg(privatewin, message, NULL); privwin_incoming_msg(privatewin, message, NULL);
rosterwin_roster();
} }
void void

View File

@ -1277,6 +1277,24 @@ cons_roster_setting(void)
else else
cons_show("Roster contact char (/roster) : none"); 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(); gint contact_indent = prefs_get_roster_contact_indent();
cons_show("Roster contact indent (/roster) : %d", contact_indent); cons_show("Roster contact indent (/roster) : %d", contact_indent);
@ -1285,12 +1303,6 @@ cons_roster_setting(void)
else else
cons_show("Roster resource (/roster) : hide"); 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(); gint resource_indent = prefs_get_roster_resource_indent();
cons_show("Roster resource indent (/roster) : %d", resource_indent); cons_show("Roster resource indent (/roster) : %d", resource_indent);
@ -1354,6 +1366,15 @@ cons_roster_setting(void)
else else
cons_show("Roster rooms (/roster) : hide"); cons_show("Roster rooms (/roster) : hide");
char *priv = prefs_get_string(PREF_ROSTER_PRIVATE);
if (g_strcmp0(priv, "room") == 0) {
cons_show("Roster private (/roster) : room");
} else if (g_strcmp0(priv, "group") == 0) {
cons_show("Roster private (/roster) : group");
} else {
cons_show("Roster private (/roster) : OFF");
}
char *rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS); char *rooms_pos = prefs_get_string(PREF_ROSTER_ROOMS_POS);
cons_show("Roster rooms position (/roster) : %s", rooms_pos); cons_show("Roster rooms position (/roster) : %s", rooms_pos);
prefs_free_string(rooms_pos); prefs_free_string(rooms_pos);

View File

@ -494,7 +494,7 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
indent--; indent--;
} }
} }
char ch = prefs_get_roster_contact_char(); char ch = prefs_get_roster_room_char();
if (ch) { if (ch) {
g_string_append_printf(msg, "%c", ch); g_string_append_printf(msg, "%c", ch);
} }
@ -519,6 +519,75 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
} else { } else {
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM)); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
} }
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;
while (curr) {
ProfPrivateWin *privwin = curr->data;
win_sub_newline_lazy(layout->subwin);
GString *privmsg = g_string_new(" ");
indent = prefs_get_roster_contact_indent();
current_indent = 0;
if (indent > 0) {
current_indent += indent;
while (indent > 0) {
g_string_append(privmsg, " ");
indent--;
}
}
// TODO add preference
indent = prefs_get_roster_resource_indent();
if (indent > 0) {
current_indent += indent;
while (indent > 0) {
g_string_append(privmsg, " ");
indent--;
}
}
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);
}
ch = prefs_get_roster_private_char();
if (ch) {
g_string_append_printf(privmsg, "%c", ch);
}
g_string_append(privmsg, privwin->fulljid + strlen(mucwin->roomjid) + 1);
if ((g_strcmp0(unreadpos, "after") == 0) && privwin->unread > 0) {
g_string_append_printf(privmsg, " (%d)", privwin->unread);
}
prefs_free_string(unreadpos);
if (privwin->unread > 0) {
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
} else {
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
}
win_sub_print(layout->subwin, privmsg->str, FALSE, wrap, current_indent);
if (privwin->unread > 0) {
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
} else {
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
}
g_string_free(privmsg, TRUE);
curr = g_list_next(curr);
}
g_list_free(privs);
}
prefs_free_string(privpref);
} }
static int static int
@ -539,6 +608,82 @@ _compare_rooms_unread(ProfMucWin *a, ProfMucWin *b)
} }
} }
void
_rosterwin_private_chats(ProfLayoutSplit *layout)
{
GList *privs = wins_get_private_chats(NULL);
if (privs || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
win_sub_newline_lazy(layout->subwin);
wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
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");
if (prefs_get_boolean(PREF_ROSTER_COUNT)) {
g_string_append_printf(title_str, " (%d)", g_list_length(privs));
}
gboolean wrap = prefs_get_boolean(PREF_ROSTER_WRAP);
win_sub_print(layout->subwin, title_str->str, FALSE, wrap, 1);
g_string_free(title_str, TRUE);
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER));
GList *curr = privs;
while (curr) {
ProfPrivateWin *privwin = curr->data;
win_sub_newline_lazy(layout->subwin);
GString *privmsg = g_string_new(" ");
int indent = prefs_get_roster_contact_indent();
int current_indent = 0;
if (indent > 0) {
current_indent += indent;
while (indent > 0) {
g_string_append(privmsg, " ");
indent--;
}
}
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);
}
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) {
g_string_append_printf(privmsg, " (%d)", privwin->unread);
}
prefs_free_string(unreadpos);
if (privwin->unread > 0) {
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
} else {
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
}
win_sub_print(layout->subwin, privmsg->str, FALSE, wrap, current_indent);
if (privwin->unread > 0) {
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
} else {
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
}
g_string_free(privmsg, TRUE);
curr = g_list_next(curr);
}
g_list_free(privs);
}
}
void void
_rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline) _rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline)
{ {
@ -560,7 +705,7 @@ _rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline)
} }
g_list_free(rooms); g_list_free(rooms);
// if this group has contacts, or if we want to show empty groups // if there are active rooms, or if we want to show empty groups
if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) { if (rooms_sorted || prefs_get_boolean(PREF_ROSTER_EMPTY)) {
if (newline) { if (newline) {
win_sub_newline_lazy(layout->subwin); win_sub_newline_lazy(layout->subwin);
@ -588,6 +733,12 @@ _rosterwin_rooms(ProfLayoutSplit *layout, gboolean newline)
} }
g_list_free(rooms_sorted); g_list_free(rooms_sorted);
char *privpref = prefs_get_string(PREF_ROSTER_PRIVATE);
if (g_strcmp0(privpref, "group") == 0) {
_rosterwin_private_chats(layout);
}
prefs_free_string(privpref);
} }
void void

View File

@ -172,6 +172,31 @@ wins_get_private(const char *const fulljid)
return NULL; return NULL;
} }
GList*
wins_get_private_chats(const char *const roomjid)
{
GList *result = NULL;
GString *prefix = g_string_new(roomjid);
g_string_append(prefix, "/");
GList *values = g_hash_table_get_values(windows);
GList *curr = values;
while (curr) {
ProfWin *window = curr->data;
if (window->type == WIN_PRIVATE) {
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
if (roomjid == NULL || g_str_has_prefix(privatewin->fulljid, prefix->str)) {
result = g_list_append(result, privatewin);
}
}
curr = g_list_next(curr);
}
g_list_free(values);
g_string_free(prefix, TRUE);
return result;
}
ProfWin* ProfWin*
wins_get_current(void) wins_get_current(void)
{ {

View File

@ -46,6 +46,7 @@ ProfWin* wins_new_muc_config(const char *const roomjid, DataForm *form);
ProfWin* wins_new_private(const char *const fulljid); ProfWin* wins_new_private(const char *const fulljid);
gboolean wins_chat_exists(const char *const barejid); gboolean wins_chat_exists(const char *const barejid);
GList* wins_get_private_chats(const char *const roomjid);
ProfWin* wins_get_console(void); ProfWin* wins_get_console(void);
ProfChatWin* wins_get_chat(const char *const barejid); ProfChatWin* wins_get_chat(const char *const barejid);

View File

@ -116,6 +116,9 @@ roster.rooms=
roster.rooms.order= roster.rooms.order=
roster.rooms.unread= roster.rooms.unread=
roster.rooms.pos= roster.rooms.pos=
roster.rooms.char=
roster.private=
roster.private.char=
occupants= occupants=
occupants.size= occupants.size=
occupants.jid= occupants.jid=

View File

@ -96,7 +96,7 @@ roster.offline=true
roster.empty=false roster.empty=false
roster.by=group roster.by=group
roster.order=presence roster.order=presence
roster.unread=before roster.unread=after
roster.count=true roster.count=true
roster.priority=false roster.priority=false
roster.size=25 roster.size=25
@ -113,8 +113,10 @@ roster.status=true
roster.contacts=true roster.contacts=true
roster.rooms=true roster.rooms=true
roster.rooms.order=name roster.rooms.order=name
roster.rooms.unread=before roster.rooms.unread=after
roster.rooms.pos=last roster.rooms.pos=last
roster.rooms.char=#
roster.private=room
occupants=true occupants=true
occupants.size=15 occupants.size=15
occupants.jid=false occupants.jid=false

View File

@ -43,6 +43,9 @@ roster.rooms=true
roster.rooms.order=unread roster.rooms.order=unread
roster.rooms.unread=after roster.rooms.unread=after
roster.rooms.pos=last roster.rooms.pos=last
roster.rooms.char=#
roster.private=room
roster.private.char=/
privileges=true privileges=true
presence=true presence=true
intype=true intype=true