]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_musiconhold: Load all realtime entries, not just the first
authorlvl <digium@lvlconsultancy.nl>
Mon, 28 Sep 2020 12:42:47 +0000 (14:42 +0200)
committerlvl <digium@lvlconsultancy.nl>
Tue, 29 Sep 2020 15:00:44 +0000 (10:00 -0500)
ASTERISK-29099

Change-Id: I45636679c0fb5a5f59114c8741626631a604e8a6

res/res_musiconhold.c

index 8d1ab2aaf5c0f06d514d455cf9e479a9b9bd4f52..db7dde71ad3c7c9a43ea16a1bd68c514aa0640d6 100644 (file)
@@ -1609,19 +1609,22 @@ static struct ast_variable *load_realtime_musiconhold(const char *name)
        if (var) {
                const char *mode = ast_variable_find_in_list(var, "mode");
                if (ast_strings_equal(mode, "playlist")) {
-                       struct ast_variable *entries = ast_load_realtime("musiconhold_entry", "name", name, SENTINEL);
-                       struct ast_variable *cur = entries;
+                       struct ast_config *entries = ast_load_realtime_multientry("musiconhold_entry", "position >=", "0", "name", name, SENTINEL);
+                       char *category = NULL;
                        size_t entry_count = 0;
-                       for (; cur; cur = cur->next) {
-                               if (!strcmp(cur->name, "entry")) {
-                                       struct ast_variable *dup = ast_variable_new(cur->name, cur->value, "");
+
+                       while ((category = ast_category_browse(entries, category))) {
+                               const char *entry = ast_variable_retrieve(entries, category, "entry");
+
+                               if (entry) {
+                                       struct ast_variable *dup = ast_variable_new("entry", entry, "");
                                        if (dup) {
                                                entry_count++;
                                                ast_variable_list_append(&var, dup);
                                        }
                                }
                        }
-                       ast_variables_destroy(entries);
+                       ast_config_destroy(entries);
 
                        if (entry_count == 0) {
                                /* Behave as though this class doesn't exist */