]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
api: channel list - sort the channels by numbers by default, issue #4819
authorJaroslav Kysela <perex@perex.cz>
Fri, 5 Jan 2018 16:44:50 +0000 (17:44 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 5 Jan 2018 16:50:58 +0000 (17:50 +0100)
src/api/api_channel.c
src/channels.c
src/channels.h
src/webui/static/app/chconf.js
src/webui/webui.c

index 34706847381069d3e6b33202ef4eb7135f4790b3..a851331d9522f3c91a9a412f35f79113ecc09427 100644 (file)
@@ -37,7 +37,7 @@ static int
 api_channel_list
   ( access_t *perm, void *opaque, const char *op, htsmsg_t *args, htsmsg_t **resp )
 {
-  channel_t *ch;
+  channel_t *ch, **chlist;
   htsmsg_t *l;
   const int cfg = api_channel_is_all(perm, args);
   const int numbers = htsmsg_get_s32_or_default(args, "numbers", 0);
@@ -45,12 +45,17 @@ api_channel_list
   const int flags = (numbers ? CHANNEL_ENAME_NUMBERS : 0) |
                     (sources ? CHANNEL_ENAME_SOURCES : 0);
   char buf[128], buf1[128], ubuf[UUID_HEX_SIZE];
-  const char *name, *blank;
+  const char *name, *blank, *sort = htsmsg_get_str(args, "sort");
+  int i, count;
 
+  sort = htsmsg_get_str(args, "sort");
+  if (numbers && !sort) sort = "numname";
   blank = tvh_gettext_lang(perm->aa_lang_ui, channel_blank_name);
   l = htsmsg_create_list();
   pthread_mutex_lock(&global_lock);
-  CHANNEL_FOREACH(ch) {
+  chlist = channel_get_sorted_list(sort, cfg, &count);
+  for (i = 0; i < count; i++) {
+    ch = chlist[i];
     if (!cfg && !channel_access(ch, perm, 0)) continue;
     if (!ch->ch_enabled) {
       snprintf(buf, sizeof(buf), "{%s}",
@@ -62,6 +67,7 @@ api_channel_list
     htsmsg_add_msg(l, NULL, htsmsg_create_key_val(idnode_uuid_as_str(&ch->ch_id, ubuf), name));
   }
   pthread_mutex_unlock(&global_lock);
+  free(chlist);
   *resp = htsmsg_create_map();
   htsmsg_add_msg(*resp, "entries", l);
   
index 831fc4d653984d058b624ae554dcdf3869ef9802..7ecba2051b1d00cca747c9fd857eebd8ee2bd45c 100644 (file)
@@ -1300,13 +1300,13 @@ static sortfcn_t *channel_sort_fcn(const char *sort_type)
 }
 
 channel_t **
-channel_get_sorted_list(const char *sort_type, int *_count)
+channel_get_sorted_list(const char *sort_type, int all, int *_count)
 {
   int count = 0;
   channel_t *ch, **chlist = malloc(channels_count * sizeof(channel_t *));
 
   CHANNEL_FOREACH(ch)
-    if (ch->ch_enabled)
+    if (all || ch->ch_enabled)
       chlist[count++] = ch;
 
   assert(count <= channels_count);
index 00a75084479b9ec488fa85593c24e38acf3d4f57..47781a75d2a4455af67a625cd60f01e8a85cc5db 100644 (file)
@@ -209,7 +209,7 @@ const char *channel_get_epgid ( channel_t *ch );
 #define channel_get_id(ch)    idnode_get_short_uuid((&(ch)->ch_id))
 
 channel_t **channel_get_sorted_list
-  ( const char *sort_type, int *_count ) ;
+  ( const char *sort_type, int all, int *_count ) ;
 channel_t **channel_get_sorted_list_for_tag
   ( const char *sort_type, channel_tag_t *tag, int *_count );
 channel_tag_t **channel_tag_get_sorted_list
index 3f00b7f2fa1db36f5f9458b86562a8189baca573..6f8840eeb9503aa43d0c2327bbb925d30451ec4f 100644 (file)
@@ -24,6 +24,7 @@ tvheadend.getChannels = function() {
             'sources': tvheadend.chname_src,
         },
         event: 'channel',
+        stype: 'none',
         listeners: {
             'load': function(scope, records, options) {
                 var placeholder = Ext.data.Record.create(['key', 'val']);
index c3fde79cb345ababe01fa999ae0a9d9e096f2db8..a2f8f9c7ec0801faef3d0ca2d027ef4a4fda9cfa 100644 (file)
@@ -686,7 +686,7 @@ http_tag_list_playlist(http_connection_t *hc, int pltype)
   ctlist = channel_tag_get_sorted_list(sort, &count);
 
   if (pltype == PLAYLIST_E2 || pltype == PLAYLIST_SATIP_M3U) {
-    chlist = channel_get_sorted_list(sort, &chcount);
+    chlist = channel_get_sorted_list(sort, 0, &chcount);
   } else {
     chlist = NULL;
   }
@@ -754,7 +754,7 @@ http_channel_list_playlist(http_connection_t *hc, int pltype)
   profile = profile_validate_name(http_arg_get(&hc->hc_req_args, "profile"));
   hostpath = http_get_hostpath(hc);
   sort = http_arg_get(&hc->hc_req_args, "sort");
-  chlist = channel_get_sorted_list(sort, &count);
+  chlist = channel_get_sorted_list(sort, 0, &count);
   blank = tvh_gettext_lang(lang, channel_blank_name);
 
   htsbuf_append_str(hq, pltype == PLAYLIST_E2 ? "#NAME Tvheadend Channels\n" : "#EXTM3U\n");