about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/command/cmd_funcs.c4
-rw-r--r--src/config/preferences.c24
-rw-r--r--src/config/preferences.h4
-rw-r--r--src/config/theme.c4
-rw-r--r--src/ui/console.c10
-rw-r--r--src/ui/rosterwin.c12
6 files changed, 28 insertions, 30 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 575ccaf3..e0747d40 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -2442,8 +2442,8 @@ cmd_roster(ProfWin* window, const char* const command, gchar** args)
                 cons_show("Roster resource char removed.");
                 rosterwin_roster();
             } else {
-                prefs_set_roster_resource_char(args[2][0]);
-                cons_show("Roster resource char set to %c.", args[2][0]);
+                prefs_set_roster_resource_char(args[2]);
+                cons_show("Roster resource char set to %s.", args[2]);
                 rosterwin_roster();
             }
         } else if (g_strcmp0(args[1], "indent") == 0) {
diff --git a/src/config/preferences.c b/src/config/preferences.c
index 3bc5800f..e713598f 100644
--- a/src/config/preferences.c
+++ b/src/config/preferences.c
@@ -1134,30 +1134,22 @@ prefs_clear_roster_contact_char(void)
     g_key_file_remove_key(prefs, PREF_GROUP_UI, "roster.contact.char", NULL);
 }
 
-char
+char*
 prefs_get_roster_resource_char(void)
 {
-    char result = 0;
-
-    char* resultstr = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
-    if (!resultstr) {
-        result = 0;
-    } else {
-        result = resultstr[0];
-    }
-    free(resultstr);
+    char* result = g_key_file_get_string(prefs, PREF_GROUP_UI, "roster.resource.char", NULL);
 
     return result;
 }
 
 void
-prefs_set_roster_resource_char(char ch)
+prefs_set_roster_resource_char(char* ch)
 {
-    char str[2];
-    str[0] = ch;
-    str[1] = '\0';
-
-    g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.resource.char", str);
+    if (g_utf8_strlen(ch, 4) == 1) {
+        g_key_file_set_string(prefs, PREF_GROUP_UI, "roster.resource.char", ch);
+    } else {
+        log_error("Could not set roster resource char: %s", ch);
+    }
 }
 
 void
diff --git a/src/config/preferences.h b/src/config/preferences.h
index 2fb5b9b1..79312e76 100644
--- a/src/config/preferences.h
+++ b/src/config/preferences.h
@@ -260,8 +260,8 @@ void prefs_clear_roster_header_char(void);
 char* prefs_get_roster_contact_char(void);
 void prefs_set_roster_contact_char(char* ch);
 void prefs_clear_roster_contact_char(void);
-char prefs_get_roster_resource_char(void);
-void prefs_set_roster_resource_char(char ch);
+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);
diff --git a/src/config/theme.c b/src/config/theme.c
index 26c3c669..a3f74d94 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -438,8 +438,8 @@ _load_preferences(void)
 
     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) {
-            prefs_set_roster_resource_char(ch[0]);
+        if (ch && g_utf8_strlen(ch, 4) == 1) {
+            prefs_set_roster_resource_char(ch);
             g_free(ch);
         }
     } else {
diff --git a/src/ui/console.c b/src/ui/console.c
index d6306dcc..d86fb158 100644
--- a/src/ui/console.c
+++ b/src/ui/console.c
@@ -1491,11 +1491,13 @@ cons_roster_setting(void)
         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
+    char* resource_ch = prefs_get_roster_resource_char();
+    if (resource_ch) {
+        cons_show("Roster resource char (/roster)      : %s", resource_ch);
+        free(resource_ch);
+    } else {
         cons_show("Roster resource char (/roster)      : none");
+    }
 
     char room_ch = prefs_get_roster_room_char();
     if (room_ch)
diff --git a/src/ui/rosterwin.c b/src/ui/rosterwin.c
index a3dfffba..91b8e7cc 100644
--- a/src/ui/rosterwin.c
+++ b/src/ui/rosterwin.c
@@ -317,6 +317,7 @@ _rosterwin_unsubscribed_item(ProfLayoutSplit* layout, ProfChatWin* chatwin)
     char *ch = prefs_get_roster_contact_char();
     if (ch) {
         g_string_append_printf(msg, "%s", ch);
+        free(ch);
     }
 
     char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
@@ -379,6 +380,7 @@ _rosterwin_contact(ProfLayoutSplit* layout, PContact contact)
     char *ch = prefs_get_roster_contact_char();
     if (ch) {
         g_string_append_printf(msg, "%s", ch);
+        free(ch);
     }
 
     char* unreadpos = prefs_get_string(PREF_ROSTER_UNREAD);
@@ -527,9 +529,10 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
 
             wattron(layout->subwin, theme_attrs(resource_presence_colour));
             GString* msg = g_string_new("");
-            char ch = prefs_get_roster_resource_char();
+            char* ch = prefs_get_roster_resource_char();
             if (ch) {
-                g_string_append_printf(msg, "%c", ch);
+                g_string_append_printf(msg, "%s", ch);
+                free(ch);
             } else {
                 g_string_append(msg, " ");
             }
@@ -590,9 +593,10 @@ _rosterwin_resources(ProfLayoutSplit* layout, PContact contact, int current_inde
                     g_string_append(msg, " ");
                     this_indent--;
                 }
-                char ch = prefs_get_roster_resource_char();
+                char* ch = prefs_get_roster_resource_char();
                 if (ch) {
-                    g_string_append_printf(msg, "%c", ch);
+                    g_string_append_printf(msg, "%s", ch);
+                    free(ch);
                 }
                 g_string_append(msg, resource->name);
                 if (prefs_get_boolean(PREF_ROSTER_PRIORITY)) {