From 0ed34a4ba9799ee3a8a0ccff26aa4a93c31df1be Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 31 Aug 2017 08:57:47 +0200 Subject: [PATCH 01/40] acinclude.m4: add missing variables substitutions Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/af9f09e8c9edcd22fab9bf1e6d26cec2910f2ea0 Author: vanhofen Date: 2017-08-31 (Thu, 31 Aug 2017) Origin message was: ------------------ - acinclude.m4: add missing variables substitutions ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- acinclude.m4 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 0f67ee152..4df1f9754 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -210,14 +210,22 @@ dnl automake <= 1.6 needs this specifications AC_SUBST(CONFIGDIR) AC_SUBST(DATADIR) AC_SUBST(FONTDIR) +AC_SUBST(FONTDIR_VAR) AC_SUBST(GAMESDIR) AC_SUBST(LIBDIR) AC_SUBST(MNTDIR) AC_SUBST(PLUGINDIR) +AC_SUBST(PLUGINDIR_VAR) +AC_SUBST(WEBTVDIR) +AC_SUBST(WEBTVDIR_VAR) +AC_SUBST(PLUGINDIR_MNT) AC_SUBST(LUAPLUGINDIR) AC_SUBST(LOCALEDIR) +AC_SUBST(LOCALEDIR_VAR) AC_SUBST(THEMESDIR) +AC_SUBST(THEMESDIR_VAR) AC_SUBST(ICONSDIR) +AC_SUBST(ICONSDIR_VAR) AC_SUBST(PRIVATE_HTTPDDIR) AC_SUBST(PUBLIC_HTTPDDIR) AC_SUBST(HOSTED_HTTPDDIR) From 72d164d89d698268c7475bf0acf6f7844732e072 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 31 Aug 2017 08:59:06 +0200 Subject: [PATCH 02/40] add webtv-scripts/sources to neutrino-repo; will be auto-loaded at start Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/7a1aeb3038ed63aeabfe78e259e0ae886df600da Author: vanhofen Date: 2017-08-31 (Thu, 31 Aug 2017) Origin message was: ------------------ - add webtv-scripts/sources to neutrino-repo; will be auto-loaded at start ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- configure.ac | 1 + data/Makefile.am | 1 + data/webtv/Makefile.am | 9 + data/webtv/filmon.lua | 73 ++++ data/webtv/filmon.xml | 919 ++++++++++++++++++++++++++++++++++++++++ data/webtv/hdporntv.lua | 66 +++ data/webtv/hdporntv.xml | 7 + data/webtv/yt_live.lua | 61 +++ data/webtv/yt_live.xml | 15 + 9 files changed, 1152 insertions(+) create mode 100644 data/webtv/Makefile.am create mode 100644 data/webtv/filmon.lua create mode 100644 data/webtv/filmon.xml create mode 100644 data/webtv/hdporntv.lua create mode 100644 data/webtv/hdporntv.xml create mode 100644 data/webtv/yt_live.lua create mode 100644 data/webtv/yt_live.xml diff --git a/configure.ac b/configure.ac index cead7db89..542e38872 100644 --- a/configure.ac +++ b/configure.ac @@ -316,6 +316,7 @@ data/pictures/backgrounds/Makefile data/pictures/screensaver/Makefile data/scripts/Makefile data/themes/Makefile +data/webtv/Makefile data/y-web/Makefile data/y-web/images/Makefile data/y-web/info/Makefile diff --git a/data/Makefile.am b/data/Makefile.am index 6c1c0e1cd..5c1b89d24 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -10,6 +10,7 @@ SUBDIRS = \ pictures \ scripts \ themes \ + webtv \ y-web if BOXTYPE_TRIPLE diff --git a/data/webtv/Makefile.am b/data/webtv/Makefile.am new file mode 100644 index 000000000..f55df6a7c --- /dev/null +++ b/data/webtv/Makefile.am @@ -0,0 +1,9 @@ +installdir = $(WEBTVDIR) + +install_DATA = \ + filmon.lua \ + filmon.xml \ + hdporntv.lua \ + hdporntv.xml \ + yt_live.lua \ + yt_live.xml diff --git a/data/webtv/filmon.lua b/data/webtv/filmon.lua new file mode 100644 index 000000000..61d118c7b --- /dev/null +++ b/data/webtv/filmon.lua @@ -0,0 +1,73 @@ +local n = neutrino(0, 0, SCREEN.X_RES, SCREEN.Y_RES); +n:checkVersion(1, 31); + +json = require "json" + +if #arg < 1 then return nil end +local _url = arg[1] +local ret = {} +local Curl = nil + +function getdata(Url) + if Url == nil then return nil end + if Curl == nil then + Curl = curl.new() + end + local ret, data = Curl:download{ url=Url, A="Mozilla/5.0"} + if ret == CURL.OK then + return data + else + return nil + end +end + +function getVideoData(url) + if url == nil then return 0 end + local data = getdata('http://www.filmon.com/tv/channel/info/' .. url) + if data == nil then return 0 end + + local data = json:decode(data) + if data==nil then return 0 end + data = data['data'] + if data==nil then return 0 end + + local title=data['title'] + if title==nil then name='nil' end + title=title .. ' - filmon' + + data = data['streams'] + if data==nil then return 0 end + + local highurl=nil + local lowurl=nil + local quality=nil + local surl=nil + for i,stream in ipairs(data) do + quality=stream['quality'] + surl=stream['url'] + if (quality=='high')or(quality=='HD') then + if (stream['watch-timeout']>=3600)and(surl:find('mustbeasubscriber')==nil) then + highurl = surl + end + elseif (quality=='low')or(quality=='SD') then + lowurl = surl + end + end + local count=0 + if highurl ~= nil then + --if lowurl ~= nil then highurl=lowurl:gsub('low.stream','high.stream') end + count = 1 + ret[1]={ url = highurl, band = "1500000", name = title, res1 = "854", res2 = "480" } + end + if lowurl ~= nil then + count = count+1 + ret[count]={ url = lowurl, band = "500000", name = title, res1 = "576", res2 = "322" } + end + return count +end + +if (getVideoData(_url) > 0) then + return json:encode(ret) +end + +return nil diff --git a/data/webtv/filmon.xml b/data/webtv/filmon.xml new file mode 100644 index 000000000..f57c54f3c --- /dev/null +++ b/data/webtv/filmon.xml @@ -0,0 +1,919 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/webtv/hdporntv.lua b/data/webtv/hdporntv.lua new file mode 100644 index 000000000..f23ff397b --- /dev/null +++ b/data/webtv/hdporntv.lua @@ -0,0 +1,66 @@ + +local n = neutrino(0, 0, SCREEN.X_RES, SCREEN.Y_RES); +M = misc.new(); M:checkVersion(1, 31) +json = require "json" + +if #arg < 1 then return nil end +local _url = arg[1] +local ret = {} +local Curl = nil + +function getdata(Url) + if Url == nil then return nil end + if Curl == nil then + Curl = curl.new() + end + local ret, data = Curl:download{ url=Url, ipv4=true, A="Mozilla/5.0 (Linux; Android 5.1.1; Nexus 4 Build/LMY48M)"} + if ret == CURL.OK then + return data + else + return nil + end +end + +function getVideoData(url) + local data = getdata(url) + local count = 0 + if data then + local title = data:match("(.-)") + local newname = url:match('tv/(.-)%.html') + local url_m3u8 = data:match('stream":%s+[\'"](.-%.m3u8)[\'"]') + if url_m3u8 then + entry = {} + entry['url'] = url_m3u8 + entry['band'] = "1" + entry['res1'] = "1" + entry['res2'] = "1" + entry['name'] = "xx" + local infodata = getdata(url_m3u8) + if infodata then + local band,res1,res2 = infodata:match('BANDWIDTH=(%d+),RESOLUTION=(%d+)x(%d+)') + if band and res1 and res2 then + entry['band'] = band + entry['res1'] = res1 + entry['res2'] = res2 + end + end + if newname then + entry['name'] = newname + end + if title then + entry['name'] = title + end + count = 1 + ret[count] = {} + ret[count] = entry + end + return count + end + return 0 +end + +if (getVideoData(_url) > 0) then + return json:encode(ret) +end + +return "" diff --git a/data/webtv/hdporntv.xml b/data/webtv/hdporntv.xml new file mode 100644 index 000000000..d2b12d5d8 --- /dev/null +++ b/data/webtv/hdporntv.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/data/webtv/yt_live.lua b/data/webtv/yt_live.lua new file mode 100644 index 000000000..74da6c7ff --- /dev/null +++ b/data/webtv/yt_live.lua @@ -0,0 +1,61 @@ + +json = require "json" + +if #arg < 1 then return nil end +local _url = arg[1] +local ret = {} +local Curl = nil + +function getdata(Url) + if Url == nil then return nil end + if Curl == nil then + Curl = curl.new() + end + local ret, data = Curl:download{ url=Url, A="Mozilla/5.0"} + if ret == CURL.OK then + return data + else + return nil + end +end + +function getVideoData(url) + if url == nil then return 0 end + local data = getdata(url) + if data then + local m3u_url = data:match('hlsvp.:.(https:\\.-m3u8)') + local newname = data:match('(.-)') + if m3u_url == nil then return 0 end + m3u_url = m3u_url:gsub("\\", "") + local videodata = getdata(m3u_url) + local url = "" + local band = "" + local res1 = "" + local res2 = "" + local count = 0 + for band, res1, res2, url in videodata:gmatch('#EXT.X.STREAM.INF.BANDWIDTH=(%d+).-RESOLUTION=(%d+)x(%d+).-(http.-)\n') do + if url ~= nil then + entry = {} + entry['url'] = url + entry['band'] = band + entry['res1'] = res1 + entry['res2'] = res2 + entry['name'] = "" + if newname then + entry['name'] = newname + end + count = count + 1 + ret[count] = {} + ret[count] = entry + end + end + return count + end + return 0 +end + +if (getVideoData(_url) > 0) then + return json:encode(ret) +end + +return "" diff --git a/data/webtv/yt_live.xml b/data/webtv/yt_live.xml new file mode 100644 index 000000000..50184397e --- /dev/null +++ b/data/webtv/yt_live.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + From 7882b11d95aef5a02d7308518e17a918d21272a1 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 31 Aug 2017 15:12:58 +0200 Subject: [PATCH 03/40] webtv: update filmon.xml Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1a08c91eb08e0ce10ae11387a92256c696e88da8 Author: vanhofen Date: 2017-08-31 (Thu, 31 Aug 2017) Origin message was: ------------------ - webtv: update filmon.xml ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/webtv/filmon.xml | 416 ++++++++++++++++++++++++++++++------------ 1 file changed, 302 insertions(+), 114 deletions(-) diff --git a/data/webtv/filmon.xml b/data/webtv/filmon.xml index f57c54f3c..2098f1208 100644 --- a/data/webtv/filmon.xml +++ b/data/webtv/filmon.xml @@ -1,39 +1,37 @@ + - - - - - - - - - + + + + + - + + @@ -50,13 +48,12 @@ - - + + - @@ -64,16 +61,12 @@ + - - - - - @@ -86,16 +79,18 @@ - + + + + - @@ -103,21 +98,27 @@ + + + + - + + + @@ -132,9 +133,9 @@ + - @@ -142,16 +143,17 @@ - + + @@ -159,14 +161,16 @@ + + - + @@ -178,6 +182,7 @@ + @@ -186,85 +191,99 @@ + + + - - + + + + - - - + + + + + + + - + - + + + + + + - + + + - - + - - - + - - + + + + - @@ -272,32 +291,27 @@ - - - + - - - @@ -312,20 +326,21 @@ - + + + - + - @@ -338,22 +353,25 @@ - + - - + + + - + + + @@ -361,13 +379,17 @@ + + + + @@ -389,45 +411,47 @@ - + - - + + + + - - - + - + + + - + - - + + @@ -445,16 +469,18 @@ + - + + - + @@ -462,7 +488,6 @@ - @@ -475,6 +500,7 @@ + @@ -486,31 +512,34 @@ - + - + + + + @@ -534,7 +563,6 @@ - @@ -545,9 +573,11 @@ - + + + @@ -555,74 +585,136 @@ + + + - + + + + + + + + + + + - + + + + + - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + + - + + + + + + @@ -644,70 +736,86 @@ - - + - + + + + + + + + - + - + + + + + + + + + + + + - + - - + @@ -723,39 +831,41 @@ - - + + - + + - + - + - + + @@ -771,10 +881,16 @@ + + + + + + @@ -782,9 +898,11 @@ + - + + @@ -793,39 +911,43 @@ + + + + - + - - + - + + @@ -849,17 +971,13 @@ - - - - @@ -870,50 +988,120 @@ - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + - + + + + + + - + + - + + + - + + + + + + + + + + + + + + + + + + + + + + + From 1492ca5683ff00085e54f7106053e4869ebab1b5 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 31 Aug 2017 15:43:34 +0200 Subject: [PATCH 04/40] icons: don't install unused flag-icons Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/63991e065d370c0463a90bda8c0124c0151fc2be Author: vanhofen Date: 2017-08-31 (Thu, 31 Aug 2017) Origin message was: ------------------ - icons: don't install unused flag-icons ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/icons/locale/Makefile.am | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/icons/locale/Makefile.am b/data/icons/locale/Makefile.am index 386924c4c..467ed29d1 100644 --- a/data/icons/locale/Makefile.am +++ b/data/icons/locale/Makefile.am @@ -3,10 +3,10 @@ installdir = $(ICONSDIR) install_DATA = \ deutsch.png \ english.png \ - nederlands.png \ - slovak.png unmaintained = \ + nederlands.png \ + slovak.png \ unmaintained/bayrisch.png \ unmaintained/bosanski.png \ unmaintained/ch-baslerdeutsch.png \ @@ -20,4 +20,4 @@ unmaintained = \ unmaintained/suomi.png \ unmaintained/svenska.png -install_DATA += $(unmaintained) +#install_DATA += $(unmaintained) From 732a1522519ba3c5d53b6cf428721ae909966662 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 31 Aug 2017 22:03:32 +0200 Subject: [PATCH 05/40] add some missing icons Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/db0eb7c9a3da60a08e2eff9d7aab69361fc6cc08 Author: vanhofen Date: 2017-08-31 (Thu, 31 Aug 2017) Origin message was: ------------------ - add some missing icons ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/icons/status/ca/Makefile.am | 15 +++++++++++++++ data/icons/status/ca/ci+_green.png | Bin 0 -> 334 bytes data/icons/status/ca/ci+_grey.png | Bin 0 -> 318 bytes data/icons/status/ca/dec_card.png | Bin 0 -> 421 bytes data/icons/status/ca/dec_fta.png | Bin 0 -> 355 bytes data/icons/status/ca/dec_int.png | Bin 0 -> 378 bytes data/icons/status/ca/dec_na.png | Bin 0 -> 416 bytes data/icons/status/ca/dec_net.png | Bin 0 -> 350 bytes data/icons/status/ca/doscam_green.png | Bin 0 -> 533 bytes data/icons/status/ca/doscam_yellow.png | Bin 0 -> 548 bytes data/icons/status/ca/gbox_green.png | Bin 0 -> 552 bytes data/icons/status/ca/mgcamd_green.png | Bin 0 -> 523 bytes data/icons/status/ca/newcs_green.png | Bin 0 -> 498 bytes data/icons/status/ca/oscam_green.png | Bin 0 -> 516 bytes data/icons/status/ca/osemu_green.png | Bin 0 -> 494 bytes data/icons/status/ca/srv_green.png | Bin 0 -> 494 bytes 16 files changed, 15 insertions(+) create mode 100644 data/icons/status/ca/ci+_green.png create mode 100644 data/icons/status/ca/ci+_grey.png create mode 100644 data/icons/status/ca/dec_card.png create mode 100644 data/icons/status/ca/dec_fta.png create mode 100644 data/icons/status/ca/dec_int.png create mode 100644 data/icons/status/ca/dec_na.png create mode 100644 data/icons/status/ca/dec_net.png create mode 100644 data/icons/status/ca/doscam_green.png create mode 100644 data/icons/status/ca/doscam_yellow.png create mode 100644 data/icons/status/ca/gbox_green.png create mode 100644 data/icons/status/ca/mgcamd_green.png create mode 100644 data/icons/status/ca/newcs_green.png create mode 100644 data/icons/status/ca/oscam_green.png create mode 100644 data/icons/status/ca/osemu_green.png create mode 100644 data/icons/status/ca/srv_green.png diff --git a/data/icons/status/ca/Makefile.am b/data/icons/status/ca/Makefile.am index 2da5da09e..d7db8b6bf 100644 --- a/data/icons/status/ca/Makefile.am +++ b/data/icons/status/ca/Makefile.am @@ -4,6 +4,8 @@ install_DATA = \ biss_green.png \ biss_white.png \ biss_yellow.png \ + ci+_green.png \ + ci+_grey.png \ conax_green.png \ conax_white.png \ conax_yellow.png \ @@ -13,21 +15,34 @@ install_DATA = \ d_green.png \ d_white.png \ d_yellow.png \ + dec_card.png \ + dec_fta.png \ + dec_int.png \ + dec_na.png \ + dec_net.png \ + doscam_green.png \ + doscam_yellow.png \ + gbox_green.png \ ird_green.png \ ird_white.png \ ird_yellow.png \ + mgcamd_green.png \ nagra_green.png \ nagra_white.png \ nagra_yellow.png \ nds_green.png \ nds_white.png \ nds_yellow.png \ + newcs_green.png \ + oscam_green.png \ + osemu_green.png \ powervu_green.png \ powervu_white.png \ powervu_yellow.png \ seca_green.png \ seca_white.png \ seca_yellow.png \ + srv_green.png \ via_green.png \ via_white.png \ via_yellow.png \ diff --git a/data/icons/status/ca/ci+_green.png b/data/icons/status/ca/ci+_green.png new file mode 100644 index 0000000000000000000000000000000000000000..06e50001e71128e72bc438175f94944f327b20d6 GIT binary patch literal 334 zcmeAS@N?(olHy`uVBq!ia0vp^DnKm4!3HFsR?RmBQfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#0S_mSh^5rctrLJkw>@1PLp+YZoo3I~Y#`Ep|FVF` zL779^6>R40)?Nn>?p^*;&!S^7`-@l`mo~PhPga&5M}>5Je?8BwJo(}2X?>L$Uw=;I z*?J$Fj+*r7RVwt%e6aEb(~}o6YzzrfZVr7)4ChZ-D{M2JslquW zl`~L8_g84B?y=I?_21(2GI)=zTqv3L{#-6kU0B<5z@>1fNIn6DG%tlKji*zcqto-+F bSZ@8((|2~$x~oz^Z!&ng`njxgN@xNA@!x>s literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/ci+_grey.png b/data/icons/status/ca/ci+_grey.png new file mode 100644 index 0000000000000000000000000000000000000000..f31756c16b286810d843702ff3da21920a73ab3d GIT binary patch literal 318 zcmeAS@N?(olHy`uVBq!ia0vp^DnKm4!3HFsR?RmBQfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#0S_mSDAyjLr^kUpr#)R9Lp+W@oo2|@Vj$x3-^xtv zl)clt2cFxeuyVhDP|Cvn(PC$lJ4fakwr!gt!dezg*kK)87qrJlZG!v#@BWj78=REd zo^UNV>FIZRlgPQ9Gi(;EYBfwd$KcW~C|G!ovq5R{kx4QEbz35@Z{3osof=tpX7{?^ z5&VZYSnt1cLCz<{S^CV)+3ga0!rRZK84D-9+Ru}#R=3^xUiHdVuU2y}T(9@!&%%X; zGDoZD_bFztjmXwFE!fSsl-;E$^y&+RRaz?7WgL=wW(xm2wC~=-F27PPiwBHAZ!vhf L`njxgN@xNAbe4LW literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/dec_card.png b/data/icons/status/ca/dec_card.png new file mode 100644 index 0000000000000000000000000000000000000000..3bd0741a40df014c246465dae391d7fb894f0522 GIT binary patch literal 421 zcmV;W0b2fvP)TVuDx$;E`S#x}%h!>qAeb8Ou9be@t2j?Y}abaxBl zG&u|aw5KzOle@soG&>;HX9hulIF8|Y-qm`VrT~DVD6ZDE){s)7EXyDHgA=+1(2K&F-p|)*D`Ro-CmtCpry8pg$oWDy*DFrFz^kbjrIRJo& zP*v5aBYO!@S(eaRLkNK=ibfq-Z-=@~zTYRercO$UEXxpvA@=+I-Hs`xo=-?h39a?u zl*V+7R)@9y%r)kqw@l#waeWA6jcpvCO%CGt4A$6&5vL7by1SWtVL!eA3+;*mBfewU P00000NkvXXu0mjfx$Ckz literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/dec_fta.png b/data/icons/status/ca/dec_fta.png new file mode 100644 index 0000000000000000000000000000000000000000..002ea7e5da6c238e99fa295dcdde40604935c011 GIT binary patch literal 355 zcmeAS@N?(olHy`uVBq!ia0vp^DnKm4!3HFsR?RmBQfx`y?k)`fL2$v|<&%LToCO|{ z#S9GG!XV7ZFl&wkP>{XE)7O>#0S_m)k?aHSBM*Q=A3R+gLp+YZoo3H<$Ux%g{p&3b zEzbn@I-P&;Y(cVM)QfkScerJ{7PEg4*xT6tB0=#+onO-reb;uDkG((lJ)A!MyTXG&^SdZ*o%K4_rEAY&h64pQ%_1*38Z|8xe&$7l zUcLNzlaBh?%O{XE)7O>#0S_k+1FN)zoD%~BBfF=IV~EG`x6^F94jTxx-aq1` zApY9=hu$lubJLQnzgN$C%d6FNYQe4Yld@9|u}w6H&W&Kt-^6&lNFlg4O{Joy>es@r zd7sZs+^*uOm{{;+o{HqbiQ6~6y_#9?vywehbIO%dYdwOB3>gY;$vaNE!o}TvlvC*X zEZ@sL*Iw_k`#!fgdq1p-8lCe(5$&TU__ zm6=hIB_ezMI-u(g-@TqF*mlnT{)eiVe6B|)YQwsoIBg1QQ2ySeBDr#E^a=5AkEI2! Wr9D5C#N!VPB?eDdKbLh*2~7Y$hnj5w literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/dec_na.png b/data/icons/status/ca/dec_na.png new file mode 100644 index 0000000000000000000000000000000000000000..b412b671fa934263f5a45a5ab7e16e1686e5076a GIT binary patch literal 416 zcmV;R0bl-!P)H zK~zY`?UpfagfI|A|1dNZi+luM0r?~;SCK%XrsXEIAW^LLG>9v31VlqMc&i{bB7_Z# zpvZLgxOje^u}x{3eu&78nLQjBBGNPS)fJIj(==Y&wny?nDdlOc?+!B`4g&yf+k%-r z2Pccu0l7=bq9_0WaU9Q%zek?uAfhpEj6oQNxLhs(fUfIMmL=-C-exFCl2vPn2-ezh zZVCeczV9Q7qU}c(1i|Vx)7^i;#Bn@Y^L>9i5D_g}n%c>-Y@8p4VeY>9dkw9%G-n3@ z9LIU8Jpf?l?S`ziAflJ-?ArEAUGbBhX-sSAEkIe8J$27sc3!#|=M1c|vm4Nofp^&f z07}!;R#kP1XTunS|Ht)LAQ9=6Qip>mr63}`%gk4;_5CDY*v|(K)r6=b$tgtu0000< KMNUMnLSTX%{XE)7O>#0S_k+BO`0xYbl`6Yfl%)5Rc<;ry2GgG7xb|??^o< zQr&S!VJEXJYqZj?D>pB%$u94h#Qa9Fh?#HWQMXMF&aTZa}KgWW9c7B1fZ{=Uk!W1n6#zkm8`!-Pe* tbj&x4pDbc_-P$%SdUsK~i{FjAqPxr@>!R!(mjk`c;OXk;vd$@?2>@5GkN5xp literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/doscam_green.png b/data/icons/status/ca/doscam_green.png new file mode 100644 index 0000000000000000000000000000000000000000..38837ca70effc09ceb1fb058bdad2fe11e831912 GIT binary patch literal 533 zcmV+w0_y#VP)rgC*4HgPaws9a^lCcdR|b;#q)DbANM>xH?n9NTk3 zgV<#BVgaByUqEc)7?>C)C)nyD8Dq7%loFhCoK7bIz-qO^Znwj1Hf!XU%O!#!0Hw5+ zXTRS!#`p1he#RKWFhm^3007VP;QM|V|8RvVr3iwcoa>v_`6jVdG>Prv_51*^*=!oe zcU4$FamH9pz-=>a{B7KJ;(B}^ujdB<*LC4}UO9e>;F{YN#moBbdcDFhjNbK!RQ7Jc zrfCj-RtSOld|rBi-h;i4`YpEVB~9xOsq9N!nsW{zL}w5FDVKiqN+(HzBuQ$n-(_M$ zJfsO}nhvhC@tarrRfwVpQ4~F|!qtblMlV?9Dl-?>=!KdK3o2KcMQq~Ro)b>w7ti|_ X{2M7GDNO(X0kKI$ zK~z}7?O45P!!Q^;IRz7gm8tKLC54bJyXj~;nnDbDhprvE_8kNoif4}@OQx*x*mvk8 z6=Y0E+@&$L@n4hF6uaLfasDKoPTyHJ*>5HfDk5)&9uLvsP!S0YJ$8s#-KkgK9B$wB zF7w5F9O23S3^hZKJ5Lq>w(mL&JsxW4S@e$ZO%=!(%k-s`;GAQ(+W`P(vl$kP1x(W{ z#HZ6KT-ODqG&9a}xh%}D!}H@a#^8A#*6TF@z_Khjj+5kHtT3e%uIncK{9^NX5!rMU zk*&h>;{$+g+lB436wdEBV=P19w3ssd)Gpice109CA0Ge=!+>R3N&6~<({VT)TC2C? z@d!=RYUgjF?Ae3|gF)kGg%B8xMu`{XYp~W)zsaV(q-g#o%C_RtoO1{vDr@jhx%8z+ zItT&;L6C9%DidqsA%)jQr5Y=({pOKwD}3LF@B7zNIK8v!BPyi?rL+_;Qlu`w%C*bl z^d5E`=ei0DA;3A$)TorQ6#r>{8$tG)Nqqlu+ly=E>iGlz9}k@;tRfQ5$5H2r&c_i{ mL_)IPOl%bquP48F9=`z32iQzx+eFp?0000fk>Z)7d)7ER0LnrgwlF^bX9TCZzhi z!U9FDp^+5(S7aWK;mzm2KMal6_Ya)$l6(r#;oyw7`Z4F0J1jlg@hT%nX#x$t^IKZ(=>%K<|x04=Y3Zx1*O!XFEjJF>7^yr7d>PC)uo<0G)tJiTg6JuBa0000E{8W$nKPjz#EfAoQxZxj)VDhbC839fVR43op`er!Ns=JTG5`SQ96|`haSQ<1Znrodk65qQPrRw|q9~x0 z!u5J}(w9;`y|>Gsbi(`n-ns^0HS?P|V+^O$$yvV(8-LUZ13(l-;GBQ2+h{i1WW0;9 zaVaGjW6t{Bim~xW8y?E+0w)oK09;@G;9}V(6e_anNrBD<_Z-#C0S0c}ID5VCU zA-l`L=+6R6K=i@z|M4(;!=^H&zX@h<)ZYX!l_>*4iJ&}87V?Yd{R>rb%Q&KOaaRBU N002ovPDHLkV1oP$=Vbr@ literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/newcs_green.png b/data/icons/status/ca/newcs_green.png new file mode 100644 index 0000000000000000000000000000000000000000..04705d7a5d6320a66d14864548522ab072c8b3e9 GIT binary patch literal 498 zcmVlm(#h+eleUFrf|)} zfCP2kEC5_iXOJLsfS##$hK)Ldce@<`V6)jgY?t+HeBPeTW>~M+7>!1i^Bu>5=XtPg zyRyGE!rSe(mDR5@TU3?VRte{F9Oq&GvlVw;xAJ~&_TK#5Y#pM%Vwi}2M0v4TyhaXx zmvT8b%d#x1(L0kQ!FW8rK3^#XDJ7yPYBz_O8ASBwbflC>lH?}DJTY6<2>ZSdW^PO>2m%B_@LD%+$X$3y20bH?d#Vszf< oaAJTnP7M;Y60UjZ$uFMwFR=il4$Us;W&i*H07*qoM6N<$g2r^(SO5S3 literal 0 HcmV?d00001 diff --git a/data/icons/status/ca/oscam_green.png b/data/icons/status/ca/oscam_green.png new file mode 100644 index 0000000000000000000000000000000000000000..1a84219bfa3c2eec1a7747a5a1382aaf5c9e1e8b GIT binary patch literal 516 zcmV+f0{i`mP)7uv-se%~7N_%&^}?FluEX45 zLL4%9u>eq<&L9qPCm0zuZ+{;xaSJ}jjazVBCalh`i)qx%EEdc8J|dvUltOqo$3 zL_=UXzLoJd|Iz&c!1FvX#;S3zg8Rnha=~QMymUoTT*W=(Y%hY7B*APpgAl@4gLmue zTWrY(0L!wj;+}D~mo6=(M3N+(HTY6p`X1sqMjXf0+*E@v(t#39^aZZMKxJnvs|47O4&YT$MN0000eWm9ek zGeXJe$pXObas{Epo?&8`9AWE`$?NqRp66k)SO5T&Qjk*Od_DsJR;v|!-v?u?vTncM z0{{+(L+!q1J_rItQ3L?soI?olX?@f9=?a@<0e~?E-}lRL9oa{*-EM2+K@={?nkQ@$ zEaI*cZ_7K51I~FF4@&r_(1)_U5KfW=uIrYybzkEJx@xZvWqWaHDJ7C5X{_--=h9t> z;}~%qSCp(Xv920V)3i6Ge`OyI!w_K@4zI9M3XHKzKQ&+Bx;|^>o95jsUi4uhM5{+M z?f*1|rIb)gRURg#Y&EgA{C7R#EBlkpX{Xb7HHmAb^TzQ1@i2PAI@j5JX^o!fd}%@F kIiTB`#eNCJdra}0Z$92Ylil>43*L|*7cGhl&PmYR;et2CXYQ8!W1Bqa4;@#G z-EEHqwGIOS<^Bi~h6_R{k__`VM*rPW_7765=aj;+2i21+TUX$k;Xuh#&8 z<#O3r-|bKn%r!|V;rssIIaI+^j$BgRvHAvx$Xa(^-wpK8*HV^0vxV87HD~qRKw4`I z27^;p&NEV}o~6U#@RUPWGo+M)*80~O(ON?(b Date: Fri, 1 Sep 2017 12:31:51 +0200 Subject: [PATCH 06/40] y-web: show hostname as page-title Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/5c46967ffbefcfa90d380fd9299e74846526b836 Author: vanhofen Date: 2017-09-01 (Fri, 01 Sep 2017) Origin message was: ------------------ - y-web: show hostname as page-title ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/y-web/index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/data/y-web/index.html b/data/y-web/index.html index 44623a6f7..383e5223f 100644 --- a/data/y-web/index.html +++ b/data/y-web/index.html @@ -4,6 +4,15 @@ yWeb + From c2c811a37e28ca039aaf6d7b5c6ed6fa68623949 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 1 Sep 2017 12:31:51 +0200 Subject: [PATCH 07/40] y-web: remove white background from favicon Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f9e32b1b487f8bd303afdcd083fd80245d26b1ac Author: vanhofen Date: 2017-09-01 (Fri, 01 Sep 2017) Origin message was: ------------------ - y-web: remove white background from favicon ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/y-web/favicon.ico | Bin 894 -> 1150 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/data/y-web/favicon.ico b/data/y-web/favicon.ico index 5e17fbdcf49d5bd14e491917b35610667a681331..48c5e0d54050d526482cfed4c4d93c2421c585fc 100644 GIT binary patch literal 1150 zcmaizKQ9D97{;GHe@-M~5vO8LMW~6Z6hxy!Ln3r?2_X~`B$P@YO5tk|U*L3C$gSVY zOfp%!JA3)vJNrEEv$H$1D<%BWRQ$Kq9hO>>mH`RnPp6a~d7i5Z0_!kW<;Qfg7w`n_ zSZ|q6?$G7u%lw!|cGu-wvEDMD?7quqWqwQ}dj$88#(IlBnK3vATfeO6*PYWp1Y0g^ z`PI7q(4)5jdoFuMU4a{jJ_9`o9DvPv0wZ>94!gz`Ooek5$N1Y|SzGtf(C54Z$B=}& zAEU3qBiKDRyzVQS-J9*lhSz*WTZ9L=gc+|FE8YZL!;<$HPs1Hpe!=Til^%PJTlig1 z>M7VW?^I<%oj%*!F4(s<4o$G{v>Eo*jp?;Lp0&(?nFpKy`9|wQFO%M1q>nf06`nt( L$uC~W9`vOjipVlx literal 894 zcmbW0Pm6*;7{+JWFVJb(;~w{8?QuVbf(0ImB0;6Bp#LX=YO zKCKv)v$5kH Date: Fri, 1 Sep 2017 17:42:24 +0000 Subject: [PATCH 08/40] Makefile.am edited online with Bitbucket Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/631efffab84e9ac9ebf9ddf18c01ca2662428410 Author: vanhofen Date: 2017-09-01 (Fri, 01 Sep 2017) ------------------ This commit was generated by Migit --- data/icons/locale/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/icons/locale/Makefile.am b/data/icons/locale/Makefile.am index 467ed29d1..4b66f961e 100644 --- a/data/icons/locale/Makefile.am +++ b/data/icons/locale/Makefile.am @@ -2,7 +2,7 @@ installdir = $(ICONSDIR) install_DATA = \ deutsch.png \ - english.png \ + english.png unmaintained = \ nederlands.png \ From 660c17ad442972a27a47be67317f22a197ef907b Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 4 Sep 2017 17:17:27 +0200 Subject: [PATCH 09/40] add possibility to signalize available online-updates in infoicons Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3294d9f74defe91ec41301affdcbec95f072b6a0 Author: vanhofen Date: 2017-09-04 (Mon, 04 Sep 2017) Origin message was: ------------------ - add possibility to signalize available online-updates in infoicons ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/icons/status/info/Makefile.am | 4 +- data/icons/status/info/info4_off.png | Bin 0 -> 446 bytes data/icons/status/info/info4_on.png | Bin 0 -> 357 bytes data/locale/deutsch.locale | 2 +- data/locale/english.locale | 2 +- src/gui/Makefile.am | 1 + src/gui/update_check.cpp | 112 +++++++++++++++++++++++++++ src/gui/update_check.h | 45 +++++++++++ src/neutrino.cpp | 18 +++-- version_pseudo.h | 2 +- 10 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 data/icons/status/info/info4_off.png create mode 100644 data/icons/status/info/info4_on.png create mode 100644 src/gui/update_check.cpp create mode 100644 src/gui/update_check.h diff --git a/data/icons/status/info/Makefile.am b/data/icons/status/info/Makefile.am index 2753cb3d8..2f8451945 100644 --- a/data/icons/status/info/Makefile.am +++ b/data/icons/status/info/Makefile.am @@ -9,4 +9,6 @@ install_DATA = \ info2_off.png \ info2_on.png \ info3_off.png \ - info3_on.png + info3_on.png \ + info4_off.png \ + info4_on.png diff --git a/data/icons/status/info/info4_off.png b/data/icons/status/info/info4_off.png new file mode 100644 index 0000000000000000000000000000000000000000..1b0cf02277a265f805b3f915a672bd0fc2a99b05 GIT binary patch literal 446 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYYs>cdx@v7EBixE7H%skcZGOo1_nlNPZ!4!kK=Er?)7GN6gg5~KF{T# z+Xi8s9GAd{U4K}cdJ_^=qkLsI@{4&MSbxs#(muBhKFW0s3T9D99&vep)ZZZNvZ3Sb zT$P7%6)^8KM5BzDkRmT*;sHY<9 zCYkg1QqNRXTdPTSjZRD})6%ZmHAnE?w&eSsH$OPUsnO;UgR6MOx#USsf7G9B7WsZN zaZ;E}hSel42jK{>jSIyjm+@5DN^Qw}AQT~&ATB#QvXVuCqpAGcdx@v7EBixE7H&&xg%p{4K%q~bE{-7{$KPIE=yy0kr2S*@)d!Lu z0V*0SocWFsO^RX+24;^Y!uW*f7fRJp}gKh@^F zUZtJ2>c;9x>mM&&x%W(i`JKf2Uq>C!{WNA?wzH$dqoSkZ?y_!w&80URdTL*?+hy(2 zFfv=WVx|6UrYvWvCkA|X($8#uq41yE;^dvri +#endif + +#include +#include + +#include +#include + +#include +#include + +#include "update_check.h" + +#define C4U_SLEEP (6 * 60 * 60) // 6 hours +#define C4U_FLAGFILE FLAGDIR "/.update" + +/* ----------------------------------------------------------------- */ + +CFlashUpdateCheck::CFlashUpdateCheck() +{ + c4u_thread = 0; +} + +CFlashUpdateCheck::~CFlashUpdateCheck() +{ + stopThread(); +} + +CFlashUpdateCheck* CFlashUpdateCheck::getInstance() +{ + static CFlashUpdateCheck * c4u = NULL; + if (!c4u) + c4u = new CFlashUpdateCheck(); + + return c4u; +} + +void CFlashUpdateCheck::startThread() +{ + if (!c4u_thread) + { + printf("[CFlashUpdateCheck]: starting thread\n"); + pthread_create(&c4u_thread, NULL, c4u_proc, (void*) NULL); + pthread_detach(c4u_thread); + } +} + +void CFlashUpdateCheck::stopThread() +{ + if (c4u_thread) + { + printf("[CFlashUpdateCheck]: stopping thread\n"); + pthread_cancel(c4u_thread); + } + c4u_thread = 0; +} + +void* CFlashUpdateCheck::c4u_proc(void*) +{ + set_threadname("n:flashupdatecheck"); + + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); + + //printf("[CFlashUpdateCheck] %s: starting loop\n", __FUNCTION__); + while(1) + { + CFlashUpdate flashupdate; + + //printf("[CFlashUpdateCheck]: check for updates\n"); + if (flashupdate.checkOnlineVersion()) + { + //printf("[CFlashUpdateCheck]: update available\n"); + if (FILE *f = fopen(C4U_FLAGFILE, "w")) + fclose(f); + } + else + { + if (access(C4U_FLAGFILE, F_OK) == 0) + unlink(C4U_FLAGFILE); + } + + sleep(C4U_SLEEP); + } + return 0; +} diff --git a/src/gui/update_check.h b/src/gui/update_check.h new file mode 100644 index 000000000..bd57c814b --- /dev/null +++ b/src/gui/update_check.h @@ -0,0 +1,45 @@ +/* + update-check + + Copyright (C) 2017 'vanhofen' + Homepage: http://www.neutrino-images.de/ + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __update_check__ +#define __update_check__ + +class CFlashUpdateCheck +{ + public: + CFlashUpdateCheck(); + ~CFlashUpdateCheck(); + static CFlashUpdateCheck* getInstance(); + + void startThread(); + void stopThread(); + + private: + + pthread_t c4u_thread; + static void* c4u_proc(void *arg); + +}; + +#endif // __update_check__ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 1f535cd19..e5faeb51b 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -94,6 +94,7 @@ #include "gui/start_wizard.h" #include "gui/update_ext.h" #include "gui/update.h" +#include "gui/update_check.h" #include "gui/videosettings.h" #include "gui/audio_select.h" #include "gui/webtv_setup.h" //NI @@ -376,6 +377,7 @@ int CNeutrinoApp::loadSetup(const char * fname) else if (i==1) sprintf(cfg_value, "/var/etc/.call"); else if (i==2) sprintf(cfg_value, "/var/etc/.srv"); else if (i==3) sprintf(cfg_value, "/var/etc/.card"); + else if (i==4) sprintf(cfg_value, "/var/etc/.update"); else strcpy(cfg_value, ""); g_settings.mode_icons_flag[i] = configfile.getString(cfg_key, cfg_value); } @@ -1081,13 +1083,11 @@ void CNeutrinoApp::upgradeSetup(const char * fname) configfile.setString("usermenu_tv_yellow", g_settings.usermenu[SNeutrinoSettings::BUTTON_YELLOW]->items); } } - //NI if (g_settings.version_pseudo < "20160804110000") { if (g_settings.tmdb_api_key == "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") g_settings.tmdb_api_key = "7270f1b571c4ecbb5b204ddb7f8939b1"; } - //NI if (g_settings.version_pseudo < "20161411235900") { //convert and remove obsolete recording_tevents key @@ -1137,13 +1137,11 @@ void CNeutrinoApp::upgradeSetup(const char * fname) configfile.deleteKey("screen_width"); configfile.deleteKey("screen_height"); } - //NI if (g_settings.version_pseudo < "20170516150000") { if (g_settings.movieplayer_bisection_jump == 1) g_settings.movieplayer_bisection_jump = 5; } - //NI if (g_settings.version_pseudo < "20170606000000") { //remove CProgressBar::PB_GRAPHIC @@ -1153,13 +1151,18 @@ void CNeutrinoApp::upgradeSetup(const char * fname) g_settings.theme.progressbar_gradient = 1; } } - //NI if (g_settings.version_pseudo < "20170606215500") { //align fontsize.filebrowser_item to new default if (configfile.getInt32("fontsize.filebrowser_item", 16) == 16) configfile.setInt32("fontsize.filebrowser_item", 17); } + if (g_settings.version_pseudo < "20170904080000") + { + //add flagfile for periodically update-check + if (g_settings.mode_icons_flag[4].empty()) + g_settings.mode_icons_flag[4] = FLAGDIR "/.update"; + } g_settings.version_pseudo = NEUTRINO_VERSION_PSEUDO; configfile.setString("version_pseudo", g_settings.version_pseudo); @@ -2551,6 +2554,7 @@ TIMER_START(); TIMER_STOP("################################## after all ##################################"); if (g_settings.softupdate_autocheck) { +#if 0 hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_CHECKUPDATE_INTERNET)); hintBox->paint(); CFlashUpdate flash; @@ -2561,6 +2565,8 @@ TIMER_STOP("################################## after all ####################### } hintBox->hide(); delete hintBox; +#endif + CFlashUpdateCheck::getInstance()->startThread(); } RealRun(); @@ -4720,6 +4726,8 @@ void stop_daemons(bool stopall, bool for_flash) cs_deregister_messenger(); } + delete CFlashUpdateCheck::getInstance(); + if (for_flash) { delete cHddStat::getInstance(); delete CRecordManager::getInstance(); diff --git a/version_pseudo.h b/version_pseudo.h index 8e3fea959..5540dd3fd 100644 --- a/version_pseudo.h +++ b/version_pseudo.h @@ -1 +1 @@ -#define NEUTRINO_VERSION_PSEUDO "20170606215500" +#define NEUTRINO_VERSION_PSEUDO "20170904080000" From c081e3c1efc0a0b5ae5f700c36a448a872f090ab Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 4 Sep 2017 23:23:38 +0200 Subject: [PATCH 10/40] icons: fix color of new icon info4_off.png Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/43587b1008f5999337630c4f1e36ae09e83f4b30 Author: vanhofen Date: 2017-09-04 (Mon, 04 Sep 2017) Origin message was: ------------------ - icons: fix color of new icon info4_off.png ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/icons/status/info/info4_off.png | Bin 446 -> 461 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/data/icons/status/info/info4_off.png b/data/icons/status/info/info4_off.png index 1b0cf02277a265f805b3f915a672bd0fc2a99b05..fe55f387e545b0115609813d9e955c69b706fcf0 100644 GIT binary patch delta 386 zcmV-|0e$|y1I+`FRDTr|5>!M`CjbBeT1iAfR7l6|mAy(sK@f$%n?#~wp0RDTOP8b=^sLjV8)OG!jQR7l6|mAy*?K@`M)cb-JSMz9ksY(!Dv ziu?tFjbLFVT1_3X4;D$lug*r&zDBT2BYuD&Hd@5u3QO@XuoFbEh|QfO;V!v5B3fk1 zWp-xY&U?Es#9zbdN02lJlz>%W7H9#lzzuL}W-qx6Bso9@*nb1O1lku+GqZyv9k+*h zJv8uoa7KZBNhg^qkhBS$XT0tWGi!7&dTpX(zz(ntEau4b2x!DsAZZ4;0v3{Xo0-#9 zWh;hOG_$9U3?z*M*S*9u;7-!5q_y^tOTheq+I|990WKsRMj34V(u|cQJvx#;fkFbQ zW@gnsgIEpQIcyI1Zl6Ip%xjY z40=5pv}xcHSRP;(9h+Hs1Rw~4ci;C7cmt+@$?ze|iVxrc*fq2I@HhM)_y$vrSiKJ? RFs=Xq002ovPDHLkV1i*bn@9iv From 287add895f980c3b2d5c2265bd04e890c3fca140 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 4 Sep 2017 23:24:22 +0200 Subject: [PATCH 11/40] update-check: move init of object CFlashUpdate out of while-loop Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/432b2b055d830b0d3b39c7a1fbfc0d1c9c4ef284 Author: vanhofen Date: 2017-09-04 (Mon, 04 Sep 2017) Origin message was: ------------------ - update-check: move init of object CFlashUpdate out of while-loop ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/update_check.cpp | 4 ++-- src/gui/update_check.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/update_check.cpp b/src/gui/update_check.cpp index 65019f960..1cc14bac1 100644 --- a/src/gui/update_check.cpp +++ b/src/gui/update_check.cpp @@ -88,11 +88,11 @@ void* CFlashUpdateCheck::c4u_proc(void*) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); + CFlashUpdate flashupdate; + //printf("[CFlashUpdateCheck] %s: starting loop\n", __FUNCTION__); while(1) { - CFlashUpdate flashupdate; - //printf("[CFlashUpdateCheck]: check for updates\n"); if (flashupdate.checkOnlineVersion()) { diff --git a/src/gui/update_check.h b/src/gui/update_check.h index bd57c814b..808757787 100644 --- a/src/gui/update_check.h +++ b/src/gui/update_check.h @@ -39,7 +39,6 @@ class CFlashUpdateCheck pthread_t c4u_thread; static void* c4u_proc(void *arg); - }; #endif // __update_check__ From 3bb2a8323b56dbf3aa5a6834a1f43f4e0a02ea60 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:04:15 +0200 Subject: [PATCH 12/40] nhttpd: enable mod_sendfile.sendAll by default Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f1b443c9b134441f5111f49ba567f87bc5920a49 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: enable mod_sendfile.sendAll by default ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 2 +- src/nhttpd/yhttpd.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 01eaecb32..c6b35ce9e 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -100,7 +100,7 @@ #define CACHE_DIR "/tmp/.cache" #define HTTPD_ERRORPAGE "/Y_ErrorPage.yhtm" #define HTTPD_SENDFILE_EXT "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg" -#define HTTPD_SENDFILE_ALL "false" +#define HTTPD_SENDFILE_ALL "true" #define HTTPD_LANGUAGEDIR "languages" #define HTTPD_DEFAULT_LANGUAGE "English" #define AUTHUSER "root" diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 1aa0c55be..076b19220 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -504,7 +504,7 @@ void Cyhttpd::ReadConfig(void) { if (Config->getInt32("configfile.version") < 2) { Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT); Config->setInt32("configfile.version", CONF_VERSION); - Config->setString("mod_sendfile.sendAll", "false"); + Config->setString("mod_sendfile.sendAll", HTTPD_SENDFILE_ALL); Config->saveConfig(HTTPD_CONFIGFILE); } // Add Defaults for Version 4 From be1d2ef80bc9bfd62c02b04445fe565554c2d3fb Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:04:15 +0200 Subject: [PATCH 13/40] nhttpd: change default password 'coolstream' => 'ni' Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3031aafdaa47f199acf78a81225fcaef271b2fde Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: change default password 'coolstream' => 'ni' ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/nhttpd.conf.in | 2 +- src/nhttpd/yconfig.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nhttpd/nhttpd.conf.in b/src/nhttpd/nhttpd.conf.in index 57757c2d8..c2e7c4b05 100644 --- a/src/nhttpd/nhttpd.conf.in +++ b/src/nhttpd/nhttpd.conf.in @@ -8,7 +8,7 @@ WebsiteMain.hosted_directory=@TARGET_HOSTED_HTTPDDIR@ configfile.version=4 mod_auth.authenticate=false mod_auth.no_auth_client= -mod_auth.password=coolstream +mod_auth.password=ni mod_auth.username=root mod_cache.cache_directory=/tmp/.cache mod_sendfile.mime_types=htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:application/octet-stream diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index c6b35ce9e..5f5e91c8f 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -125,7 +125,7 @@ #endif #ifdef CONFIG_SYSTEM_TUXBOX_COOLSTREAM -#define AUTHPASSWORD "coolstream" +#define AUTHPASSWORD "ni" #define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR #undef Y_CONFIG_BUILD_AS_DAEMON // No Daemon #endif From 54e12b52ab526286e413842e4f5f75f933a24a80 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:04:15 +0200 Subject: [PATCH 14/40] nhttpd: change default language to 'Deutsch' Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9f04aeabdade2f2aa2a7b9b1dfea343989d9932d Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: change default language to 'Deutsch' ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 5f5e91c8f..477b836c2 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -102,7 +102,7 @@ #define HTTPD_SENDFILE_EXT "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg" #define HTTPD_SENDFILE_ALL "true" #define HTTPD_LANGUAGEDIR "languages" -#define HTTPD_DEFAULT_LANGUAGE "English" +#define HTTPD_DEFAULT_LANGUAGE "Deutsch" #define AUTHUSER "root" #define HTTPD_CONFIGDIR CONFIGDIR From fa9fe08da0f484eef0162990c154dfd0f9046650 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:04:15 +0200 Subject: [PATCH 15/40] nhttpd: fix typo in AUTH_NAME_MSG Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c59a16775f2d1ca4b80262eeee26d9a4eb91cd8a Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: fix typo in AUTH_NAME_MSG ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 477b836c2..b81c09d66 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -33,7 +33,7 @@ #define IADDR_LOCAL "127.0.0.1" // local IP #define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded) #define YHTTPD_NAME "yhttpd_core" // Webserver name (Name of yhttpd-core!) -#define AUTH_NAME_MSG "yhhtpd" // Name in Authentication Dialogue +#define AUTH_NAME_MSG "yhttpd" // Name in Authentication Dialogue #define CONF_VERSION 4 // Version of yhttpd-conf file #define HTTPD_KEEPALIVE_TIMEOUT 500000 // Timeout for Keep-Alive in mircoseconds //============================================================================= From 7d64c25b87bada96071a09e0c1508bf611478e3b Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:04:16 +0200 Subject: [PATCH 16/40] nhttpd: align mod_sendfile.mime_types to HTTPD_SENDFILE_EXT Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f3bba1011fc1420443a0366e3548b093ca0b2de3 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: align mod_sendfile.mime_types to HTTPD_SENDFILE_EXT ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/nhttpd.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nhttpd/nhttpd.conf.in b/src/nhttpd/nhttpd.conf.in index c2e7c4b05..5d249142b 100644 --- a/src/nhttpd/nhttpd.conf.in +++ b/src/nhttpd/nhttpd.conf.in @@ -11,7 +11,7 @@ mod_auth.no_auth_client= mod_auth.password=ni mod_auth.username=root mod_cache.cache_directory=/tmp/.cache -mod_sendfile.mime_types=htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:application/octet-stream +mod_sendfile.mime_types=htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg mod_weblog.log_format= mod_weblog.logfile=/tmp/yhttpd.log server.chroot= From 53e127a371135e236820dbd49979de6c86f05a3a Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:04:16 +0200 Subject: [PATCH 17/40] nhttpd: remove non-working and outdated Y_CONFIG_BUILD_AS_DAEMON switch Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/cfe519bfd91e0d6ff538f3a8b1130d8753a5d4f1 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: remove non-working and outdated Y_CONFIG_BUILD_AS_DAEMON switch ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 2 - src/nhttpd/yhttpd.cpp | 130 +----------------------------------------- 2 files changed, 2 insertions(+), 130 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index b81c09d66..33aeee8c3 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -61,7 +61,6 @@ #define Y_CONFIG_FEATUE_SENDFILE_CAN_ACCESS_ALL y // Add Feature: every file can be accessed (use carefully: security!!) //#define Y_CONFIG_FEATURE_CHROOT y // Add Feature: Use Change Root for Security //#define Y_CONFIG_FEATURE_HTTPD_USER y // Add Feature: Set User for yhttpd-Process -#define Y_CONFIG_BUILD_AS_DAEMON y // Build as a Daemon #define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading //----------------------------------------------------------------------------- // Define/Undefine Features forced by CONFIG_SYSTEM_xxx @@ -127,7 +126,6 @@ #ifdef CONFIG_SYSTEM_TUXBOX_COOLSTREAM #define AUTHPASSWORD "ni" #define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR -#undef Y_CONFIG_BUILD_AS_DAEMON // No Daemon #endif //----------------------------------------------------------------------------- // Aggregated definitions diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 076b19220..163444d5d 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -63,47 +63,14 @@ static CNeutrinoAPI *NeutrinoAPI; #endif //============================================================================= -// Main: Main Entry, Command line passing, Webserver Instance creation & Loop +// Main: Main Entry, Webserver thread //============================================================================= -volatile sig_atomic_t Cyhttpd::sig_do_shutdown = 0; -//----------------------------------------------------------------------------- -// Signal Handling -//----------------------------------------------------------------------------- -#ifdef Y_CONFIG_BUILD_AS_DAEMON -static void sig_catch(int msignal) -{ - aprintf("!!! SIGNAL !!! :%d!\n",msignal); - switch (msignal) { - // case SIGTERM: - // case SIGINT: - case SIGPIPE: - aprintf("got signal PIPE, nice!\n"); - break; - case SIGHUP: - case SIGUSR1: - aprintf("got signal HUP/USR1, reading config\n"); - if (yhttpd) - yhttpd->ReadConfig(); - break; - default: - aprintf("No special SIGNAL-Handler:%d!\n",msignal); - // log_level_printf(1, "Got SIGTERM\n"); - Cyhttpd::sig_do_shutdown = 1; - yhttpd->stop_webserver(); - delete yhttpd; - exit(EXIT_SUCCESS); //FIXME: return to main() some way... - break; - - } -} -#endif - -//----------------------------------------------------------------------------- void yhttpd_reload_config() { if (yhttpd) yhttpd->ReadConfig(); } + //----------------------------------------------------------------------------- // Main Entry //----------------------------------------------------------------------------- @@ -118,7 +85,6 @@ void thread_cleanup (void *p) y = NULL; } -#ifndef Y_CONFIG_BUILD_AS_DAEMON void * nhttpd_main_thread(void *) { set_threadname("yweb:main_thread"); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); @@ -153,98 +119,6 @@ void * nhttpd_main_thread(void *) { aprintf("Main end\n"); return (void *) EXIT_SUCCESS; } -#endif -#ifdef Y_CONFIG_BUILD_AS_DAEMON -int main(int argc, char **argv) -{ - aprintf("Webserver %s\n", WEBSERVERNAME); - bool do_fork = true; - yhttpd = new Cyhttpd(); - if(!yhttpd) - { - aprintf("Error initializing WebServer\n"); - return EXIT_FAILURE; - } - for (int i = 1; i < argc; i++) - { - if ((!strncmp(argv[i], "-d", 2)) || (!strncmp(argv[i], "--debug", 7))) - { - CLogging::getInstance()->setDebug(true); - do_fork = false; - } - else if ((!strncmp(argv[i], "-f", 2)) || (!strncmp(argv[i], "--fork", 6))) - { - do_fork = false; - } - else if ((!strncmp(argv[i], "-h", 2)) || (!strncmp(argv[i], "--help", 6))) - { - yhttpd->usage(stdout); - return EXIT_SUCCESS; - } - else if ((!strncmp(argv[i], "-v", 2)) || (!strncmp(argv[i],"--version", 9))) - { - yhttpd->version(stdout); - return EXIT_SUCCESS; - } - else if ((!strncmp(argv[i], "-t", 2)) || (!strncmp(argv[i],"--thread-off", 12))) - { - yhttpd->flag_threading_off = true; - } - else if ((!strncmp(argv[i], "-l", 2)) ) - { - if(argv[i][2] >= '0' && argv[i][2] <= '9') - CLogging::getInstance()->LogLevel = (argv[i][2]-'0'); - } - else - { - yhttpd->usage(stderr); - return EXIT_FAILURE; - } - } - // setup signal catching (subscribing) - signal(SIGPIPE, sig_catch); - signal(SIGINT, sig_catch); - signal(SIGHUP, sig_catch); - signal(SIGUSR1, sig_catch); - signal(SIGTERM, sig_catch); - signal(SIGCLD, SIG_IGN); - // signal(SIGALRM, sig_catch); - - yhttpd->hooks_attach(); - yhttpd->ReadConfig(); - if(yhttpd->Configure()) - { - // Start Webserver: fork ist if not in debug mode - aprintf("Webserver starting...\n"); - if (do_fork) - { - log_level_printf(9,"do fork\n"); - switch (fork()) { - case -1: - dperror("fork"); - return -1; - case 0: - break; - default: - return EXIT_SUCCESS; - } - - if (setsid() == -1) - { - dperror("Error setsid"); - return EXIT_FAILURE; - } - } - dprintf("Start in Debug-Mode\n"); // non forked debugging loop - - yhttpd->run(); - } - delete yhttpd; - - aprintf("Main end\n"); - return EXIT_SUCCESS; -} -#endif //============================================================================= // Class yhttpd //============================================================================= From 03f7ec5a37e2a2816e07486723eda1c55de878a4 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:10:10 +0200 Subject: [PATCH 18/40] nhttpd: remove obsolete function to show commandline help Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/5a5ce505690a4fbe854a74bd18b87a78b7e81813 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: remove obsolete function to show commandline help ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yhttpd.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 163444d5d..6b24e014e 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -229,20 +229,6 @@ void Cyhttpd::version(FILE *dest) { fprintf(dest, "%s - Webserver v%s\n", HTTPD_NAME, HTTPD_VERSION); } -//----------------------------------------------------------------------------- -// Show Usage -//----------------------------------------------------------------------------- -void Cyhttpd::usage(FILE *dest) { - version(dest); - fprintf(dest, "command line parameters:\n"); - fprintf(dest, "-d, --debug enable debugging code (implies -f)\n"); - fprintf(dest, "-f, --fork do not fork\n"); - fprintf(dest, "-h, --help display this text and exit\n\n"); - fprintf(dest, "-v, --version display version and exit\n"); - fprintf(dest, "-l, set loglevel (0 .. 9)\n"); - fprintf(dest, "-t, --thread-off set threading off\n"); -} - //----------------------------------------------------------------------------- // Stop WebServer //----------------------------------------------------------------------------- From 21583169c81e926153941781165cda32c54a7e41 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:13:00 +0200 Subject: [PATCH 19/40] nhttpd: supplement to previous commit 03f7ec5a37e2a2816e07486723eda1c55de878a4 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/023dd950bdf401710f6f11db32a94c88d380f1d5 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: supplement to previous commit 03f7ec5a37e2a2816e07486723eda1c55de878a4 ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yhttpd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/nhttpd/yhttpd.h b/src/nhttpd/yhttpd.h index eff8a9ac8..f0a7478ef 100644 --- a/src/nhttpd/yhttpd.h +++ b/src/nhttpd/yhttpd.h @@ -39,7 +39,6 @@ public: bool Configure(); void stop_webserver(); // Remove Hooks, Stop Webserver static void version(FILE *dest);// Show Webserver Version - static void usage(FILE *dest); // Show command line usage // Hooks void hooks_attach(); // Add a Hook-Class to HookList void hooks_detach(); // Remove a Hook-Class from HookList From b06ccc3719f315734a5abb1d9d42b682c1ef4053 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 00:18:14 +0200 Subject: [PATCH 20/40] nhttpd: just cosmetics (remove annoying linebreaks) Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2cf08d8cbe7fd81f796382161db8de25fc11bb67 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: just cosmetics (remove annoying linebreaks) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yhttpd.cpp | 70 ++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 47 deletions(-) diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 6b24e014e..fedee02d9 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -331,29 +331,19 @@ void Cyhttpd::ReadConfig(void) { CConfigFile OrgConfig = *Config; Config->clear(); - Config->setInt32("server.log.loglevel", OrgConfig.getInt32( - "LogLevel", 0)); + Config->setInt32("server.log.loglevel", OrgConfig.getInt32("LogLevel", 0)); Config->setInt32("configfile.version", CONF_VERSION); Config->setString("webserver.websites", "WebsiteMain"); - Config->setBool("webserver.threading", OrgConfig.getBool("THREADS", - true)); - Config->setInt32("WebsiteMain.port", OrgConfig.getInt32("Port", - HTTPD_STANDARD_PORT)); - Config->setString("WebsiteMain.directory", OrgConfig.getString( - "PrivatDocRoot", PRIVATEDOCUMENTROOT)); + Config->setBool("webserver.threading", OrgConfig.getBool("THREADS", true)); + Config->setInt32("WebsiteMain.port", OrgConfig.getInt32("Port", HTTPD_STANDARD_PORT)); + Config->setString("WebsiteMain.directory", OrgConfig.getString("PrivatDocRoot", PRIVATEDOCUMENTROOT)); if (!OrgConfig.getString("PublicDocRoot", "").empty()) - Config->setString("WebsiteMain.override_directory", - OrgConfig.getString("PublicDocRoot", - PRIVATEDOCUMENTROOT)); + Config->setString("WebsiteMain.override_directory", OrgConfig.getString("PublicDocRoot", PRIVATEDOCUMENTROOT)); // mod_auth - Config->setString("mod_auth.username", OrgConfig.getString( - "AuthUser", AUTHUSER)); - Config->setString("mod_auth.password", OrgConfig.getString( - "AuthPassword", AUTHPASSWORD)); - Config->setString("mod_auth.no_auth_client", OrgConfig.getString( - "NoAuthClient", "")); - Config->setString("mod_auth.authenticate", OrgConfig.getString( - "Authenticate", "false")); + Config->setString("mod_auth.username", OrgConfig.getString("AuthUser", AUTHUSER)); + Config->setString("mod_auth.password", OrgConfig.getString("AuthPassword", AUTHPASSWORD)); + Config->setString("mod_auth.no_auth_client", OrgConfig.getString("NoAuthClient", "")); + Config->setString("mod_auth.authenticate", OrgConfig.getString("Authenticate", "false")); Config->setString("mod_sendfile.mime_types", HTTPD_SENDFILE_EXT); @@ -392,29 +382,19 @@ void Cyhttpd::ReadConfig(void) { #endif // get variables - webserver->init(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT), - Config->getBool("webserver.threading", true)); + webserver->init(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT), Config->getBool("webserver.threading", true)); // informational use - ConfigList["WebsiteMain.port"] = itoa(Config->getInt32("WebsiteMain.port", - HTTPD_STANDARD_PORT)); - ConfigList["webserver.threading"] = Config->getString( - "webserver.threading", "true"); - ConfigList["configfile.version"] = Config->getInt32("configfile.version", - CONF_VERSION); - ConfigList["server.log.loglevel"] = itoa(Config->getInt32( - "server.log.loglevel", 0)); - ConfigList["server.no_keep-alive_ips"] = Config->getString( - "server.no_keep-alive_ips", ""); - webserver->conf_no_keep_alive_ips = Config->getStringVector( - "server.no_keep-alive_ips"); + ConfigList["WebsiteMain.port"] = itoa(Config->getInt32("WebsiteMain.port", HTTPD_STANDARD_PORT)); + ConfigList["webserver.threading"] = Config->getString("webserver.threading", "true"); + ConfigList["configfile.version"] = Config->getInt32("configfile.version", CONF_VERSION); + ConfigList["server.log.loglevel"] = itoa(Config->getInt32("server.log.loglevel", 0)); + ConfigList["server.no_keep-alive_ips"] = Config->getString("server.no_keep-alive_ips", ""); + webserver->conf_no_keep_alive_ips = Config->getStringVector("server.no_keep-alive_ips"); // MainSite - ConfigList["WebsiteMain.directory"] = Config->getString( - "WebsiteMain.directory", PRIVATEDOCUMENTROOT); - ConfigList["WebsiteMain.override_directory"] = Config->getString( - "WebsiteMain.override_directory", PUBLICDOCUMENTROOT); - ConfigList["WebsiteMain.hosted_directory"] = Config->getString( - "WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); + ConfigList["WebsiteMain.directory"] = Config->getString("WebsiteMain.directory", PRIVATEDOCUMENTROOT); + ConfigList["WebsiteMain.override_directory"] = Config->getString("WebsiteMain.override_directory", PUBLICDOCUMENTROOT); + ConfigList["WebsiteMain.hosted_directory"] = Config->getString("WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); ConfigList["Tuxbox.DisplayLogos"] = Config->getString("Tuxbox.DisplayLogos", "true"); // Check location of logos @@ -447,15 +427,12 @@ void Cyhttpd::ReadConfig(void) { CySocket::initSSL(); #endif ConfigList["server.user_name"] = Config->getString("server.user_name", ""); - ConfigList["server.group_name"] - = Config->getString("server.group_name", ""); + ConfigList["server.group_name"] = Config->getString("server.group_name", ""); ConfigList["server.chroot"] = Config->getString("server.chroot", ""); // language - ConfigList["Language.directory"] = Config->getString("Language.directory", - HTTPD_LANGUAGEDIR); - ConfigList["Language.selected"] = Config->getString("Language.selected", - HTTPD_DEFAULT_LANGUAGE); + ConfigList["Language.directory"] = Config->getString("Language.directory", HTTPD_LANGUAGEDIR); + ConfigList["Language.selected"] = Config->getString("Language.selected", HTTPD_DEFAULT_LANGUAGE); yhttpd->ReadLanguage(); // Read App specifig settings by Hook @@ -473,7 +450,6 @@ void Cyhttpd::ReadConfig(void) { void Cyhttpd::ReadLanguage(void) { // Init Class vars CLanguage *lang = CLanguage::getInstance(); - log_level_printf(3, "ReadLanguage:%s\n", - ConfigList["Language.selected"].c_str()); + log_level_printf(3, "ReadLanguage:%s\n", ConfigList["Language.selected"].c_str()); lang->setLanguage(ConfigList["Language.selected"]); } From 4c90ce863fc33b7a2f960aa9aeb02101a38ae699 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 08:49:02 +0200 Subject: [PATCH 21/40] nhttpd: remove obsolete CONFIG_SYSTEM_TUXBOX_COOLSTREAM switch Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f53335d5331af281bc2c8b7fc9a2848ab684823d Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: remove obsolete CONFIG_SYSTEM_TUXBOX_COOLSTREAM switch ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 19 ++++++------------- src/nhttpd/yhttpd.cpp | 7 ++++--- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 33aeee8c3..2ba1fa4d8 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -22,8 +22,7 @@ // System Choice ONE choice //----------------------------------------------------------------------------- #ifndef CONFIG_SYSTEM_BY_COMPILER // use Compiler directive to set CONFIG_SYSTEM -//#define CONFIG_SYSTEM_TUXBOX y // Tuxbox project -#define CONFIG_SYSTEM_TUXBOX_COOLSTREAM y // Tuxbox project for coolstream +#define CONFIG_SYSTEM_TUXBOX y // Tuxbox project #endif //----------------------------------------------------------------------------- // General central Definitions @@ -70,11 +69,12 @@ //#undef Y_CONFIG_HAVE_SENDFILE // Sendfile does not work for SSL, but we'll fallback to send //#endif -#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM) +#ifdef CONFIG_SYSTEM_TUXBOX #define Y_CONFIG_FEATURE_UPLOAD y #define Y_CONFIG_USE_YPARSER y #define Y_CONFIG_USE_AUTHHOOK y #endif + #ifdef Y_CONFIG_FEATURE_KEEP_ALIVE #define HTTP_PROTOCOL "HTTP/1.1" #else @@ -102,12 +102,15 @@ #define HTTPD_SENDFILE_ALL "true" #define HTTPD_LANGUAGEDIR "languages" #define HTTPD_DEFAULT_LANGUAGE "Deutsch" + #define AUTHUSER "root" +#define AUTHPASSWORD "ni" #define HTTPD_CONFIGDIR CONFIGDIR #define HTTPD_CONFIGFILE HTTPD_CONFIGDIR"/nhttpd.conf" #define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf" #define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR +#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR #define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf" #define MOVIEBROWSER_CONFIGFILE CONFIGDIR"/moviebrowser.conf" #define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR @@ -117,16 +120,6 @@ #define ZAPITXMLPATH CONFIGDIR"/zapit" #define TUXBOX_LOGOS_URL LOGODIR //NI -// switch for Box differences -#ifdef CONFIG_SYSTEM_TUXBOX -#define AUTHPASSWORD "dbox2" -#define PRIVATEDOCUMENTROOT DATADIR "/neutrino/httpd-y" -#endif - -#ifdef CONFIG_SYSTEM_TUXBOX_COOLSTREAM -#define AUTHPASSWORD "ni" -#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR -#endif //----------------------------------------------------------------------------- // Aggregated definitions //----------------------------------------------------------------------------- diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index fedee02d9..5895342eb 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -56,7 +56,8 @@ static CmodCache mod_cache; // static instance #endif //----------------------------------------------------------------------------- -#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM) + +#ifdef CONFIG_SYSTEM_TUXBOX #include "neutrinoapi.h" #include static CNeutrinoAPI *NeutrinoAPI; @@ -254,7 +255,7 @@ void Cyhttpd::hooks_attach() { CyhookHandler::attach(testhook); #endif -#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM) +#ifdef CONFIG_SYSTEM_TUXBOX NeutrinoAPI = new CNeutrinoAPI(); CyhookHandler::attach(NeutrinoAPI->NeutrinoYParser); CyhookHandler::attach(NeutrinoAPI->ControlAPI); @@ -292,7 +293,7 @@ void Cyhttpd::hooks_detach() { delete testhook; #endif -#if defined(CONFIG_SYSTEM_TUXBOX) || defined(CONFIG_SYSTEM_TUXBOX_COOLSTREAM) +#ifdef CONFIG_SYSTEM_TUXBOX CyhookHandler::detach(NeutrinoAPI->NeutrinoYParser); #else #ifdef Y_CONFIG_USE_YPARSER From dfa47c7aa045ce10807b5086271e27358e3a0536 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 08:49:02 +0200 Subject: [PATCH 22/40] nhttpd: resort defines Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1be350e3c4ee353a8dc587b603f96eaeb6cbc5b4 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: resort defines ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 2ba1fa4d8..ecaed2872 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -109,16 +109,18 @@ #define HTTPD_CONFIGDIR CONFIGDIR #define HTTPD_CONFIGFILE HTTPD_CONFIGDIR"/nhttpd.conf" #define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf" -#define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR -#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR #define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf" #define MOVIEBROWSER_CONFIGFILE CONFIGDIR"/moviebrowser.conf" + +#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR +#define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR #define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR #define HOSTEDDOCUMENTURL "/hosted/" #define EXTRASDOCUMENTROOT HOSTED_HTTPDDIR"/extras" #define EXTRASDOCUMENTURL "/hosted/extras" + #define ZAPITXMLPATH CONFIGDIR"/zapit" -#define TUXBOX_LOGOS_URL LOGODIR //NI +#define TUXBOX_LOGOS_URL LOGODIR //----------------------------------------------------------------------------- // Aggregated definitions From b30533cb99ab28d6e7ecea4a3a863f4fee36bf67 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 08:49:02 +0200 Subject: [PATCH 23/40] nhttpd: just code-reformats; fix indentation Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b02fb1fded9f98dbe433480a4497e473fe2e8dbc Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: just code-reformats; fix indentation ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 114 +++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index ecaed2872..c6cb52edc 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -21,52 +21,52 @@ //----------------------------------------------------------------------------- // System Choice ONE choice //----------------------------------------------------------------------------- -#ifndef CONFIG_SYSTEM_BY_COMPILER // use Compiler directive to set CONFIG_SYSTEM -#define CONFIG_SYSTEM_TUXBOX y // Tuxbox project +#ifndef CONFIG_SYSTEM_BY_COMPILER // use Compiler directive to set CONFIG_SYSTEM +#define CONFIG_SYSTEM_TUXBOX y // Tuxbox project #endif //----------------------------------------------------------------------------- // General central Definitions //----------------------------------------------------------------------------- -#define HTTPD_VERSION "3.4.0" // Webserver version (can be overloaded) -#define YHTTPD_VERSION "1.3.2" // Webserver version (Version of yhttpd-core!) -#define IADDR_LOCAL "127.0.0.1" // local IP -#define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded) -#define YHTTPD_NAME "yhttpd_core" // Webserver name (Name of yhttpd-core!) -#define AUTH_NAME_MSG "yhttpd" // Name in Authentication Dialogue -#define CONF_VERSION 4 // Version of yhttpd-conf file -#define HTTPD_KEEPALIVE_TIMEOUT 500000 // Timeout for Keep-Alive in mircoseconds +#define HTTPD_VERSION "3.4.0" // Webserver version (can be overloaded) +#define YHTTPD_VERSION "1.3.2" // Webserver version (Version of yhttpd-core!) +#define IADDR_LOCAL "127.0.0.1" // local IP +#define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded) +#define YHTTPD_NAME "yhttpd_core" // Webserver name (Name of yhttpd-core!) +#define AUTH_NAME_MSG "yhttpd" // Name in Authentication Dialogue +#define CONF_VERSION 4 // Version of yhttpd-conf file +#define HTTPD_KEEPALIVE_TIMEOUT 500000 // Timeout for Keep-Alive in mircoseconds //============================================================================= // Features wanted //============================================================================= //----------------------------------------------------------------------------- // modules //----------------------------------------------------------------------------- -//#define Y_CONFIG_USE_TESTHOOK y // Add mod: "Test-Hook" (hook example) -#define Y_CONFIG_USE_YPARSER y // Add mod: "y-Parsing" -#define Y_CONFIG_USE_AUTHHOOK y // Add mod: "Authentication" -#define Y_CONFIG_USE_WEBLOG y // Add mod: "WebLogging" -#define Y_CONFIG_USE_CACHE y // Add mod: Can cache production pages -#define Y_CONFIG_USE_SENDFILE y // Add mod: can send static files (mandantory) +//#define Y_CONFIG_USE_TESTHOOK y // Add mod: "Test-Hook" (hook example) +#define Y_CONFIG_USE_YPARSER y // Add mod: "y-Parsing" +#define Y_CONFIG_USE_AUTHHOOK y // Add mod: "Authentication" +#define Y_CONFIG_USE_WEBLOG y // Add mod: "WebLogging" +#define Y_CONFIG_USE_CACHE y // Add mod: Can cache production pages +#define Y_CONFIG_USE_SENDFILE y // Add mod: can send static files (mandantory) //----------------------------------------------------------------------------- // Features & Build //----------------------------------------------------------------------------- -#define Y_CONFIG_FEATURE_CHECK_PORT_AUTORITY y // System: Port < 1024 need Admin-Privileges-Check -#define Y_CONFIG_HAVE_SENDFILE y // System: Have *IX SendFile -#define Y_CONFIG_FEATURE_UPLOAD y // Add Feature: File Upload POST Command -#define Y_CONFIG_USE_HOSTEDWEB y // Add Feature: Use HOSTED Web -#define Y_CONFIG_FEATURE_SHOW_SERVER_CONFIG y // Add Feature (in yParser): add /y/server-config -//#define Y_CONFIG_USE_OPEN_SSL y // Add Feature: use openSSL +#define Y_CONFIG_FEATURE_CHECK_PORT_AUTORITY y // System: Port < 1024 need Admin-Privileges-Check +#define Y_CONFIG_HAVE_SENDFILE y // System: Have *IX SendFile +#define Y_CONFIG_FEATURE_UPLOAD y // Add Feature: File Upload POST Command +#define Y_CONFIG_USE_HOSTEDWEB y // Add Feature: Use HOSTED Web +#define Y_CONFIG_FEATURE_SHOW_SERVER_CONFIG y // Add Feature (in yParser): add /y/server-config +//#define Y_CONFIG_USE_OPEN_SSL y // Add Feature: use openSSL //#define Y_CONFIG_FEATURE_KEEP_ALIVE y // Add Feature: Keep-alive //FIXME: does not work correctly now #define Y_CONFIG_FEATUE_SENDFILE_CAN_ACCESS_ALL y // Add Feature: every file can be accessed (use carefully: security!!) -//#define Y_CONFIG_FEATURE_CHROOT y // Add Feature: Use Change Root for Security +//#define Y_CONFIG_FEATURE_CHROOT y // Add Feature: Use Change Root for Security //#define Y_CONFIG_FEATURE_HTTPD_USER y // Add Feature: Set User for yhttpd-Process -#define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading +#define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading //----------------------------------------------------------------------------- // Define/Undefine Features forced by CONFIG_SYSTEM_xxx // Dependencies //----------------------------------------------------------------------------- //#ifdef Y_CONFIG_USE_OPEN_SSL -//#undef Y_CONFIG_HAVE_SENDFILE // Sendfile does not work for SSL, but we'll fallback to send +//#undef Y_CONFIG_HAVE_SENDFILE // Sendfile does not work for SSL, but we'll fallback to send //#endif #ifdef CONFIG_SYSTEM_TUXBOX @@ -84,43 +84,43 @@ // Configurations for systems/OSs //============================================================================= //----------------------------------------------------------------------------- -// Configurations for LINUX (Tuxbox dbox2, coolstream) -//-----------------------------------------------------------------------,js:text/plain------ +// Configurations for LINUX (Tuxbox) +//----------------------------------------------------------------------------- #undef HTTPD_NAME -#define HTTPD_NAME "nhttpd" -#define HTTPD_STANDARD_PORT 80 -#define HTTPD_MAX_CONNECTIONS 50 -#define HTTPD_REQUEST_LOG "/tmp/httpd_log" -#define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem" -#define SSL_CA_FILE HTTPD_CONFIGDIR "/cacert.pem" -#define LOG_FILE "/tmp/yhhtpd.log" -#define LOG_FORMAT "" -#define UPLOAD_TMP_FILE "/tmp/upload.tmp" -#define CACHE_DIR "/tmp/.cache" -#define HTTPD_ERRORPAGE "/Y_ErrorPage.yhtm" -#define HTTPD_SENDFILE_EXT "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg" -#define HTTPD_SENDFILE_ALL "true" -#define HTTPD_LANGUAGEDIR "languages" -#define HTTPD_DEFAULT_LANGUAGE "Deutsch" +#define HTTPD_NAME "nhttpd" +#define HTTPD_STANDARD_PORT 80 +#define HTTPD_MAX_CONNECTIONS 50 +#define HTTPD_REQUEST_LOG "/tmp/httpd_log" +#define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem" +#define SSL_CA_FILE HTTPD_CONFIGDIR "/cacert.pem" +#define LOG_FILE "/tmp/yhhtpd.log" +#define LOG_FORMAT "" +#define UPLOAD_TMP_FILE "/tmp/upload.tmp" +#define CACHE_DIR "/tmp/.cache" +#define HTTPD_ERRORPAGE "/Y_ErrorPage.yhtm" +#define HTTPD_SENDFILE_EXT "htm:text/html,html:text/html,xml:text/xml,txt:text/plain,jpg:image/jpeg,jpeg:image/jpeg,gif:image/gif,png:image/png,bmp:image/bmp,css:text/css,js:text/plain,yjs:text/plain,img:application/octet-stream,ico:image/x-icon,m3u:application/octet-stream,tar:application/octet-stream,gz:text/x-gzip,ts:video/MP2T,mkv:video/x-matroska,avi:video/avi,mp3:audio/mpeg,ogg:audio/ogg" +#define HTTPD_SENDFILE_ALL "true" +#define HTTPD_LANGUAGEDIR "languages" +#define HTTPD_DEFAULT_LANGUAGE "Deutsch" -#define AUTHUSER "root" -#define AUTHPASSWORD "ni" +#define AUTHUSER "root" +#define AUTHPASSWORD "ni" -#define HTTPD_CONFIGDIR CONFIGDIR -#define HTTPD_CONFIGFILE HTTPD_CONFIGDIR"/nhttpd.conf" -#define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf" -#define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf" -#define MOVIEBROWSER_CONFIGFILE CONFIGDIR"/moviebrowser.conf" +#define HTTPD_CONFIGDIR CONFIGDIR +#define HTTPD_CONFIGFILE HTTPD_CONFIGDIR"/nhttpd.conf" +#define YWEB_CONFIGFILE HTTPD_CONFIGDIR"/Y-Web.conf" +#define NEUTRINO_CONFIGFILE CONFIGDIR"/neutrino.conf" +#define MOVIEBROWSER_CONFIGFILE CONFIGDIR"/moviebrowser.conf" -#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR -#define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR -#define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR -#define HOSTEDDOCUMENTURL "/hosted/" -#define EXTRASDOCUMENTROOT HOSTED_HTTPDDIR"/extras" -#define EXTRASDOCUMENTURL "/hosted/extras" +#define PRIVATEDOCUMENTROOT PRIVATE_HTTPDDIR +#define PUBLICDOCUMENTROOT PUBLIC_HTTPDDIR +#define HOSTEDDOCUMENTROOT HOSTED_HTTPDDIR +#define HOSTEDDOCUMENTURL "/hosted/" +#define EXTRASDOCUMENTROOT HOSTED_HTTPDDIR"/extras" +#define EXTRASDOCUMENTURL "/hosted/extras" -#define ZAPITXMLPATH CONFIGDIR"/zapit" -#define TUXBOX_LOGOS_URL LOGODIR +#define ZAPITXMLPATH CONFIGDIR"/zapit" +#define TUXBOX_LOGOS_URL LOGODIR //----------------------------------------------------------------------------- // Aggregated definitions From a8fbb121b4d7839941a90d022639508160741534 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 08:49:02 +0200 Subject: [PATCH 24/40] nhttpd: remove unused mod_testhook Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ed68d9dfc6ff4aec5ff197bd8a7d2031adf12fee Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: remove unused mod_testhook ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 1 - src/nhttpd/yhttpd.cpp | 10 ---------- src/nhttpd/yhttpd_mods/Makefile.am | 6 +++++- src/nhttpd/yhttpd_mods/mod_auth.cpp | 2 +- src/nhttpd/yhttpd_mods/mod_testhook.cpp | 17 ----------------- src/nhttpd/yhttpd_mods/mod_testhook.h | 21 --------------------- 6 files changed, 6 insertions(+), 51 deletions(-) delete mode 100644 src/nhttpd/yhttpd_mods/mod_testhook.cpp delete mode 100644 src/nhttpd/yhttpd_mods/mod_testhook.h diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index c6cb52edc..2dfbc6248 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -41,7 +41,6 @@ //----------------------------------------------------------------------------- // modules //----------------------------------------------------------------------------- -//#define Y_CONFIG_USE_TESTHOOK y // Add mod: "Test-Hook" (hook example) #define Y_CONFIG_USE_YPARSER y // Add mod: "y-Parsing" #define Y_CONFIG_USE_AUTHHOOK y // Add mod: "Authentication" #define Y_CONFIG_USE_WEBLOG y // Add mod: "WebLogging" diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 5895342eb..e7b66ddff 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -250,11 +250,6 @@ void Cyhttpd::hooks_attach() { CyhookHandler::attach(auth); #endif -#ifdef Y_CONFIG_USE_TESTHOOK - testhook = new CTesthook(); - CyhookHandler::attach(testhook); -#endif - #ifdef CONFIG_SYSTEM_TUXBOX NeutrinoAPI = new CNeutrinoAPI(); CyhookHandler::attach(NeutrinoAPI->NeutrinoYParser); @@ -288,11 +283,6 @@ void Cyhttpd::hooks_detach() { delete auth; #endif -#ifdef Y_CONFIG_USE_TESTHOOK - CyhookHandler::detach(testhook); - delete testhook; -#endif - #ifdef CONFIG_SYSTEM_TUXBOX CyhookHandler::detach(NeutrinoAPI->NeutrinoYParser); #else diff --git a/src/nhttpd/yhttpd_mods/Makefile.am b/src/nhttpd/yhttpd_mods/Makefile.am index a08445dbd..240d14804 100644 --- a/src/nhttpd/yhttpd_mods/Makefile.am +++ b/src/nhttpd/yhttpd_mods/Makefile.am @@ -16,5 +16,9 @@ AM_CPPFLAGS += -fno-rtti -fno-exceptions -D_FILE_OFFSET_BITS=64 noinst_LIBRARIES = libyhttpdmods.a libyhttpdmods_a_SOURCES = \ - mod_yparser.cpp mod_testhook.cpp mod_auth.cpp mod_cache.cpp mod_sendfile.cpp mod_weblog.cpp + mod_auth.cpp \ + mod_cache.cpp \ + mod_sendfile.cpp \ + mod_weblog.cpp \ + mod_yparser.cpp diff --git a/src/nhttpd/yhttpd_mods/mod_auth.cpp b/src/nhttpd/yhttpd_mods/mod_auth.cpp index 3defe1ca8..50c1f6da5 100644 --- a/src/nhttpd/yhttpd_mods/mod_auth.cpp +++ b/src/nhttpd/yhttpd_mods/mod_auth.cpp @@ -1,6 +1,6 @@ //============================================================================= // YHTTPD -// TestHook +// mod_auth : Authentication //============================================================================= #include diff --git a/src/nhttpd/yhttpd_mods/mod_testhook.cpp b/src/nhttpd/yhttpd_mods/mod_testhook.cpp deleted file mode 100644 index 6f3195203..000000000 --- a/src/nhttpd/yhttpd_mods/mod_testhook.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//============================================================================= -// YHTTPD -// TestHook -//============================================================================= - -#include "mod_testhook.h" - -THandleStatus CTesthook::Hook_SendResponse(CyhookHandler *hh) -{ - THandleStatus status = HANDLED_NONE; - if(hh->UrlData["filename"] == "test2") - { - hh->yresult = "test it 2222\n"; - status = HANDLED_READY; - } - return status; -} diff --git a/src/nhttpd/yhttpd_mods/mod_testhook.h b/src/nhttpd/yhttpd_mods/mod_testhook.h deleted file mode 100644 index 1f6ed9f2e..000000000 --- a/src/nhttpd/yhttpd_mods/mod_testhook.h +++ /dev/null @@ -1,21 +0,0 @@ -//============================================================================= -// YHTTPD -// TestHook -//============================================================================= -#ifndef TESTHOOK_H_ -#define TESTHOOK_H_ - - -#include -class CTesthook : public Cyhook -{ -public: - THandleStatus Hook_SendResponse(CyhookHandler *hh); - CTesthook(){}; - ~CTesthook(){}; - - virtual std::string getHookName(void) {return std::string("Testhook");} - -}; -#endif /*TESTHOOK_H_*/ - From e71967d7b5c0f83427fdaa786695ae33ec431e91 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 08:49:02 +0200 Subject: [PATCH 25/40] nhttpd: sort entrys in Makefile.am Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ebe593ac90b2b7ccb1be4f17bf565aff9f0090b8 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: sort entrys in Makefile.am ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/Makefile.am | 4 +++- src/nhttpd/yhttpd_core/Makefile.am | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/nhttpd/tuxboxapi/Makefile.am b/src/nhttpd/tuxboxapi/Makefile.am index f208f7b02..2376c052c 100644 --- a/src/nhttpd/tuxboxapi/Makefile.am +++ b/src/nhttpd/tuxboxapi/Makefile.am @@ -21,5 +21,7 @@ AM_CPPFLAGS += \ noinst_LIBRARIES = libnhttpd_tuxboxapi.a libnhttpd_tuxboxapi_a_SOURCES = \ - neutrinoapi.cpp neutrinoyparser.cpp controlapi.cpp + controlapi.cpp \ + neutrinoapi.cpp \ + neutrinoyparser.cpp diff --git a/src/nhttpd/yhttpd_core/Makefile.am b/src/nhttpd/yhttpd_core/Makefile.am index 5d95d0e77..6f97b33c1 100644 --- a/src/nhttpd/yhttpd_core/Makefile.am +++ b/src/nhttpd/yhttpd_core/Makefile.am @@ -17,6 +17,13 @@ AM_CPPFLAGS += -fno-rtti -fno-exceptions -D_FILE_OFFSET_BITS=64 noinst_LIBRARIES = libyhttpd.a libyhttpd_a_SOURCES = \ - ylogging.cpp helper.cpp ylanguage.cpp\ - ywebserver.cpp yconnection.cpp yrequest.cpp yresponse.cpp yhook.cpp ysocket.cpp + helper.cpp \ + yconnection.cpp \ + yhook.cpp \ + ylanguage.cpp\ + ylogging.cpp \ + yrequest.cpp \ + yresponse.cpp \ + ysocket.cpp \ + ywebserver.cpp From 347bf90f5d46f21722b594b4766d8c455f7ac6de Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 09:31:31 +0200 Subject: [PATCH 26/40] nhttpd: small re-sorts; TODO: fix $Revision$ replacements Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3a105efe84720585fc1278d28d20bbe85d6f0b80 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: small re-sorts; TODO: fix $Revision$ replacements ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/controlapi.h | 8 ++++---- src/nhttpd/tuxboxapi/neutrinoyparser.h | 3 ++- src/nhttpd/yhttpd_mods/mod_auth.h | 16 ++++++---------- src/nhttpd/yhttpd_mods/mod_cache.h | 8 ++++---- src/nhttpd/yhttpd_mods/mod_sendfile.h | 6 +++--- src/nhttpd/yhttpd_mods/mod_weblog.h | 4 ++-- src/nhttpd/yhttpd_mods/mod_yparser.h | 3 ++- 7 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/nhttpd/tuxboxapi/controlapi.h b/src/nhttpd/tuxboxapi/controlapi.h index 38679f3f2..2bfbe0bf1 100644 --- a/src/nhttpd/tuxboxapi/controlapi.h +++ b/src/nhttpd/tuxboxapi/controlapi.h @@ -155,10 +155,10 @@ public: CControlAPI(CNeutrinoAPI *_NeutrinoAPI); // virtual functions for HookHandler/Hook - virtual std::string getHookName(void) {return std::string("mod_ControlAPI");} - virtual std::string getHookVersion(void) {return std::string("$Revision$");} - virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); - virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); + virtual std::string getHookName(void) {return std::string("mod_ControlAPI");} + virtual std::string getHookVersion(void) {return std::string("$Revision$");} + virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); + virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); }; #endif /* __nhttpd_neutrinocontrolapi_hpp__ */ diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.h b/src/nhttpd/tuxboxapi/neutrinoyparser.h index 2dbb77984..4a8e2ec9d 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.h +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.h @@ -65,8 +65,9 @@ public: // virtual functions for BaseClass virtual std::string YWeb_cgi_func(CyhookHandler *hh, std::string ycmd); + // virtual functions for HookHandler/Hook - virtual std::string getHookName(void) {return std::string("mod_NeutrinoYParser-Coolstream");} + virtual std::string getHookName(void) {return std::string("mod_NeutrinoYParser");} virtual std::string getHookVersion(void) {return std::string("$Revision$");} virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); diff --git a/src/nhttpd/yhttpd_mods/mod_auth.h b/src/nhttpd/yhttpd_mods/mod_auth.h index 4efdcd8e9..9c44c325f 100644 --- a/src/nhttpd/yhttpd_mods/mod_auth.h +++ b/src/nhttpd/yhttpd_mods/mod_auth.h @@ -17,16 +17,12 @@ public: } ; - // Hooks - virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); - virtual std::string getHookName(void) { - return std::string("mod_auth"); - } - virtual std::string getHookVersion(void) { - return std::string("$Revision$"); - } - virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, - CStringList &ConfigList); + // virtual functions for HookHandler/Hook + virtual std::string getHookName(void) {return std::string("mod_auth");} + virtual std::string getHookVersion(void) {return std::string("$Revision$");} + virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); + virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); + protected: bool CheckAuth(CyhookHandler *hh); std::string decodeBase64(const char *b64buffer); diff --git a/src/nhttpd/yhttpd_mods/mod_cache.h b/src/nhttpd/yhttpd_mods/mod_cache.h index d4172e6aa..b380c1b38 100644 --- a/src/nhttpd/yhttpd_mods/mod_cache.h +++ b/src/nhttpd/yhttpd_mods/mod_cache.h @@ -48,12 +48,12 @@ public: static void RemoveCategoryFromCache(std::string category); static void DeleteCache(void); - // Hooks + // virtual functions for HookHandler/Hook + virtual std::string getHookName(void) {return std::string("mod_cache");} + virtual std::string getHookVersion(void) {return std::string("$Revision$");} virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); - virtual std::string getHookVersion(void) {return std::string("$Revision$");} - virtual std::string getHookName(void) {return std::string("mod_cache");} - virtual THandleStatus Hook_ReadConfig(CConfigFile *Config,CStringList &ConfigList); + virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); }; #endif /* __yhttpd_mod_cache_h__ */ diff --git a/src/nhttpd/yhttpd_mods/mod_sendfile.h b/src/nhttpd/yhttpd_mods/mod_sendfile.h index e4294a25f..4dfa4af7f 100644 --- a/src/nhttpd/yhttpd_mods/mod_sendfile.h +++ b/src/nhttpd/yhttpd_mods/mod_sendfile.h @@ -28,11 +28,11 @@ public: CmodSendfile(){}; ~CmodSendfile(void){}; - // Hooks - virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); -// virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); + // virtual functions for HookHandler/Hook virtual std::string getHookName(void) {return std::string("mod_sendfile");} virtual std::string getHookVersion(void) {return std::string("$Revision$");} + virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); +// virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); }; diff --git a/src/nhttpd/yhttpd_mods/mod_weblog.h b/src/nhttpd/yhttpd_mods/mod_weblog.h index bcdf2d96e..4e0d5ca02 100644 --- a/src/nhttpd/yhttpd_mods/mod_weblog.h +++ b/src/nhttpd/yhttpd_mods/mod_weblog.h @@ -33,10 +33,10 @@ public: void AddLogEntry_ELF(CyhookHandler *hh); bool printf(const char *fmt, ...); - // Hooks - virtual THandleStatus Hook_EndConnection(CyhookHandler *hh); + // virtual functions for HookHandler/Hook virtual std::string getHookName(void) {return std::string("mod_weblog");} virtual std::string getHookVersion(void) {return std::string("$Revision$");} + virtual THandleStatus Hook_EndConnection(CyhookHandler *hh); virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); }; #endif // __yhttpd_mod_weblog_h__ diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.h b/src/nhttpd/yhttpd_mods/mod_yparser.h index dc6209ec2..bbe7f9dac 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.h +++ b/src/nhttpd/yhttpd_mods/mod_yparser.h @@ -113,9 +113,10 @@ public: // virtual functions for BaseClass virtual std::string YWeb_cgi_func(CyhookHandler *hh, std::string ycmd); + // virtual functions for HookHandler/Hook - virtual std::string getHookVersion(void) {return std::string("$Revision$");} virtual std::string getHookName(void) {return "mod_yparser";} + virtual std::string getHookVersion(void) {return std::string("$Revision$");} virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); }; From 3af3f44e89487efdfa8c3a5081d5c6ede63479fb Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 09:34:03 +0200 Subject: [PATCH 27/40] nhttpd: fix indentations Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/cfd1a3016002de075b84594dc5cea7dd7fd584d7 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - nhttpd: fix indentations ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/neutrinoyparser.cpp | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 7bc179349..77a042619 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -111,26 +111,26 @@ THandleStatus CNeutrinoYParser::Hook_ReadConfig(CConfigFile *Config, CStringList //============================================================================= const CNeutrinoYParser::TyFuncCall CNeutrinoYParser::yFuncCallList[]= { - {"mount-get-list", &CNeutrinoYParser::func_mount_get_list}, - {"mount-set-values", &CNeutrinoYParser::func_mount_set_values}, - {"get_bouquets_as_dropdown", &CNeutrinoYParser::func_get_bouquets_as_dropdown}, - {"get_bouquets_as_templatelist",&CNeutrinoYParser::func_get_bouquets_as_templatelist}, - {"get_actual_bouquet_number", &CNeutrinoYParser::func_get_actual_bouquet_number}, - {"get_channels_as_dropdown", &CNeutrinoYParser::func_get_channels_as_dropdown}, + {"mount-get-list", &CNeutrinoYParser::func_mount_get_list}, + {"mount-set-values", &CNeutrinoYParser::func_mount_set_values}, + {"get_bouquets_as_dropdown", &CNeutrinoYParser::func_get_bouquets_as_dropdown}, + {"get_bouquets_as_templatelist", &CNeutrinoYParser::func_get_bouquets_as_templatelist}, + {"get_actual_bouquet_number", &CNeutrinoYParser::func_get_actual_bouquet_number}, + {"get_channels_as_dropdown", &CNeutrinoYParser::func_get_channels_as_dropdown}, {"get_bouquets_with_epg", &CNeutrinoYParser::func_get_bouquets_with_epg}, {"get_actual_channel_id", &CNeutrinoYParser::func_get_actual_channel_id}, - {"get_logo_name", &CNeutrinoYParser::func_get_logo_name}, - {"get_mode", &CNeutrinoYParser::func_get_mode}, - {"get_video_pids", &CNeutrinoYParser::func_get_video_pids}, - {"get_audio_pid", &CNeutrinoYParser::func_get_radio_pid}, - {"get_audio_pids_as_dropdown", &CNeutrinoYParser::func_get_audio_pids_as_dropdown}, - {"umount_get_list", &CNeutrinoYParser::func_unmount_get_list}, + {"get_logo_name", &CNeutrinoYParser::func_get_logo_name}, + {"get_mode", &CNeutrinoYParser::func_get_mode}, + {"get_video_pids", &CNeutrinoYParser::func_get_video_pids}, + {"get_audio_pid", &CNeutrinoYParser::func_get_radio_pid}, + {"get_audio_pids_as_dropdown", &CNeutrinoYParser::func_get_audio_pids_as_dropdown}, + {"umount_get_list", &CNeutrinoYParser::func_unmount_get_list}, {"get_partition_list", &CNeutrinoYParser::func_get_partition_list}, - {"get_boxtype", &CNeutrinoYParser::func_get_boxtype}, - {"get_boxmodel", &CNeutrinoYParser::func_get_boxmodel}, + {"get_boxtype", &CNeutrinoYParser::func_get_boxtype}, + {"get_boxmodel", &CNeutrinoYParser::func_get_boxmodel}, {"get_current_stream_info", &CNeutrinoYParser::func_get_current_stream_info}, - {"get_timer_list", &CNeutrinoYParser::func_get_timer_list}, - {"set_timer_form", &CNeutrinoYParser::func_set_timer_form}, + {"get_timer_list", &CNeutrinoYParser::func_get_timer_list}, + {"set_timer_form", &CNeutrinoYParser::func_set_timer_form}, {"bouquet_editor_main", &CNeutrinoYParser::func_bouquet_editor_main}, {"set_bouquet_edit_form", &CNeutrinoYParser::func_set_bouquet_edit_form}, //NI y-funcs From c412759bf6d551bc35688be5410dc6718382d9f2 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 16:53:34 +0200 Subject: [PATCH 28/40] yWeb: align cifs-mounts to new automount-syntax Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/fbb92e23c0829f6d8b59b25bffd6d3c7a60723c5 Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - yWeb: align cifs-mounts to new automount-syntax ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/y-web/Y_Settings_automount.yhtm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/y-web/Y_Settings_automount.yhtm b/data/y-web/Y_Settings_automount.yhtm index d8cdbf827..8368de139 100644 --- a/data/y-web/Y_Settings_automount.yhtm +++ b/data/y-web/Y_Settings_automount.yhtm @@ -102,8 +102,8 @@ function do_save2() var dir = document.f.dir.value; if(dir.indexOf("/") == 0) dir = dir.substr(1); - mstr += ((mstr!="")?",":"")+"unc="+"//"+document.f.ip.value+"/"+dir; - mstr += "%20//"+document.f.ip.value+"/"+dir; + //mstr += ((mstr!="")?",":"")+"unc="+"//"+document.f.ip.value+"/"+dir; + mstr += "%20://"+document.f.ip.value+"/"+dir; } show_waitbox(false); mstr = mstr.replace(/=/gi,",,"); From 09a38eb4b38accbc8e3af854c8e92e7af7d39dbb Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 5 Sep 2017 21:24:28 +0200 Subject: [PATCH 29/40] remove unused system/ansi.h Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/08b7fa9286e27647ff67d6ec271ba3d7406a302f Author: vanhofen Date: 2017-09-05 (Tue, 05 Sep 2017) Origin message was: ------------------ - remove unused system/ansi.h ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/global.h | 1 - src/system/ansi.h | 61 ----------------------------------------------- 2 files changed, 62 deletions(-) delete mode 100644 src/system/ansi.h diff --git a/src/global.h b/src/global.h index 54ae6d816..fadfa39cf 100644 --- a/src/global.h +++ b/src/global.h @@ -24,7 +24,6 @@ */ #include -#include //NI #ifndef NEUTRINO_CPP #define NEUTRINO_CPP extern diff --git a/src/system/ansi.h b/src/system/ansi.h deleted file mode 100644 index d46131b26..000000000 --- a/src/system/ansi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ansi.h */ - -/* ANSI control codes for various neat-o terminal effects - - * Some older versions of Ultrix don't appear to be able to - * handle these escape sequences. If lowercase 'a's are being - * stripped, and/or the output of the ANSI is screwed up, you - * have the Ultrix problem. - * - * To fix the ANSI problem, try replacing the '\x1B' with '\033'. - * To fix the problem with 'a's, replace all occurrences of '\a' - * in the code with '\07'. - * - */ - -#ifndef _ANSI_H_ -#define _ANSI_H_ - -#define BEEP_CHAR '\a' -#define ESC_CHAR '\x1B' - -#define ANSI_BEGIN "\x1B[" - -#define ANSI_NORMAL "\x1B[0m" - -#define ANSI_HILITE "\x1B[1m" -#define ANSI_INVERSE "\x1B[7m" -#define ANSI_BLINK "\x1B[5m" -#define ANSI_UNDERSCORE "\x1B[4m" -#define ANSI_TRUNCATE "\x1B[=71" - -#define ANSI_INV_BLINK "\x1B[7;5m" -#define ANSI_INV_HILITE "\x1B[1;7m" -#define ANSI_BLINK_HILITE "\x1B[1;5m" -#define ANSI_INV_BLINK_HILITE "\x1B[1;5;7m" - -/* Foreground colors */ - -#define ANSI_FOR_BLACK "\x1B[30m" -#define ANSI_FOR_RED "\x1B[31m" -#define ANSI_FOR_GREEN "\x1B[32m" -#define ANSI_FOR_YELLOW "\x1B[33m" -#define ANSI_FOR_BLUE "\x1B[34m" -#define ANSI_FOR_MAGENTA "\x1B[35m" -#define ANSI_FOR_CYAN "\x1B[36m" -#define ANSI_FOR_WHITE "\x1B[37m" - -/* Background colors */ - -#define ANSI_BAC_BLACK "\x1B[40m" -#define ANSI_BAC_RED "\x1B[41m" -#define ANSI_BAC_GREEN "\x1B[42m" -#define ANSI_BAC_YELLOW "\x1B[43m" -#define ANSI_BAC_BLUE "\x1B[44m" -#define ANSI_BAC_MAGENTA "\x1B[45m" -#define ANSI_BAC_CYAN "\x1B[46m" -#define ANSI_BAC_WHITE "\x1B[47m" - -#define ANSI_END "m" - -#endif /* _ANSI_H_ */ From ac70b0ed6fdad1e4930b4ecc3b45bc3c3f9dcc56 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 6 Sep 2017 15:22:43 +0200 Subject: [PATCH 30/40] nhttpd: use PORT-defines from yconfig.h instead of "hardcoded" ports Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/0f47d66b323fb66a08afe30c1d4e864660248309 Author: vanhofen Date: 2017-09-06 (Wed, 06 Sep 2017) Origin message was: ------------------ - nhttpd: use PORT-defines from yconfig.h instead of "hardcoded" ports ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 1 + src/nhttpd/yhttpd_core/ywebserver.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 2dfbc6248..4aa07e199 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -88,6 +88,7 @@ #undef HTTPD_NAME #define HTTPD_NAME "nhttpd" #define HTTPD_STANDARD_PORT 80 +#define HTTPD_FALLBACK_PORT 8080 #define HTTPD_MAX_CONNECTIONS 50 #define HTTPD_REQUEST_LOG "/tmp/httpd_log" #define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem" diff --git a/src/nhttpd/yhttpd_core/ywebserver.cpp b/src/nhttpd/yhttpd_core/ywebserver.cpp index e1a5f149d..bfd04dbc3 100644 --- a/src/nhttpd/yhttpd_core/ywebserver.cpp +++ b/src/nhttpd/yhttpd_core/ywebserver.cpp @@ -53,7 +53,7 @@ CWebserver::CWebserver() { pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); #endif - port = 80; + port = HTTPD_STANDARD_PORT; } //----------------------------------------------------------------------------- @@ -120,14 +120,15 @@ CWebserver::~CWebserver() { bool CWebserver::run(void) { set_threadname("ywebsrv::run"); if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) { - if (port != 80) { - fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port); + if (port != HTTPD_STANDARD_PORT) { + // WebsiteMain.port in nhttpd.conf is changed by user + fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d. Abort.\n", port); return false; } - fprintf(stderr, "[yhttpd] cannot bind and listen on port 80, retrying on port 8080.\n"); - port = 8080; + fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d. Retrying port %d.\n", HTTPD_STANDARD_PORT, HTTPD_FALLBACK_PORT); + port = HTTPD_FALLBACK_PORT; if (!listenSocket.listen(port, HTTPD_MAX_CONNECTIONS)) { - fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d Abort.\n", port); + fprintf(stderr, "[yhttpd] Socket cannot bind and listen on port %d. Abort.\n", HTTPD_FALLBACK_PORT); return false; } } From 8be67cba533b7cfc7d386d5d84c95b5f87eae755 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 6 Sep 2017 15:22:43 +0200 Subject: [PATCH 31/40] nhttpd: move defines for SSL-certs after HTTPD_CONFIGDIR define Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/2bdba905a60451a40e8a930435bfdbd54c0b3281 Author: vanhofen Date: 2017-09-06 (Wed, 06 Sep 2017) Origin message was: ------------------ - nhttpd: move defines for SSL-certs after HTTPD_CONFIGDIR define ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 4aa07e199..7bcae56c8 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -91,8 +91,6 @@ #define HTTPD_FALLBACK_PORT 8080 #define HTTPD_MAX_CONNECTIONS 50 #define HTTPD_REQUEST_LOG "/tmp/httpd_log" -#define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem" -#define SSL_CA_FILE HTTPD_CONFIGDIR "/cacert.pem" #define LOG_FILE "/tmp/yhhtpd.log" #define LOG_FORMAT "" #define UPLOAD_TMP_FILE "/tmp/upload.tmp" @@ -122,6 +120,8 @@ #define ZAPITXMLPATH CONFIGDIR"/zapit" #define TUXBOX_LOGOS_URL LOGODIR +#define SSL_PEMFILE HTTPD_CONFIGDIR "/server.pem" +#define SSL_CA_FILE HTTPD_CONFIGDIR "/cacert.pem" //----------------------------------------------------------------------------- // Aggregated definitions //----------------------------------------------------------------------------- From 58c7d7daedec56aa92844f542fd40f0efb2e4978 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 6 Sep 2017 15:22:43 +0200 Subject: [PATCH 32/40] nhttpd: fix typo in LOG_FILE define Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/bb03192bdc3eb1ddf0937a00097c5d15b3a3f43f Author: vanhofen Date: 2017-09-06 (Wed, 06 Sep 2017) Origin message was: ------------------ - nhttpd: fix typo in LOG_FILE define ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/yconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 7bcae56c8..94f8954be 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -91,7 +91,7 @@ #define HTTPD_FALLBACK_PORT 8080 #define HTTPD_MAX_CONNECTIONS 50 #define HTTPD_REQUEST_LOG "/tmp/httpd_log" -#define LOG_FILE "/tmp/yhhtpd.log" +#define LOG_FILE "/tmp/yhttpd.log" #define LOG_FORMAT "" #define UPLOAD_TMP_FILE "/tmp/upload.tmp" #define CACHE_DIR "/tmp/.cache" From 0387dcd9d5da1cd564e195d0bcecbd3809628889 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 6 Sep 2017 15:22:43 +0200 Subject: [PATCH 33/40] nhttpd: de-capitalize hooknames for controlapi and neutrinoyparser Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/d24fd89cd7834a05948f768c484ccb3223cf3b24 Author: vanhofen Date: 2017-09-06 (Wed, 06 Sep 2017) Origin message was: ------------------ - nhttpd: de-capitalize hooknames for controlapi and neutrinoyparser ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/controlapi.h | 2 +- src/nhttpd/tuxboxapi/neutrinoyparser.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nhttpd/tuxboxapi/controlapi.h b/src/nhttpd/tuxboxapi/controlapi.h index 2bfbe0bf1..afa823635 100644 --- a/src/nhttpd/tuxboxapi/controlapi.h +++ b/src/nhttpd/tuxboxapi/controlapi.h @@ -155,7 +155,7 @@ public: CControlAPI(CNeutrinoAPI *_NeutrinoAPI); // virtual functions for HookHandler/Hook - virtual std::string getHookName(void) {return std::string("mod_ControlAPI");} + virtual std::string getHookName(void) {return std::string("controlapi");} virtual std::string getHookVersion(void) {return std::string("$Revision$");} virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); virtual THandleStatus Hook_PrepareResponse(CyhookHandler *hh); diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.h b/src/nhttpd/tuxboxapi/neutrinoyparser.h index 4a8e2ec9d..31404d08d 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.h +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.h @@ -67,7 +67,7 @@ public: virtual std::string YWeb_cgi_func(CyhookHandler *hh, std::string ycmd); // virtual functions for HookHandler/Hook - virtual std::string getHookName(void) {return std::string("mod_NeutrinoYParser");} + virtual std::string getHookName(void) {return std::string("neutrinoyparser");} virtual std::string getHookVersion(void) {return std::string("$Revision$");} virtual THandleStatus Hook_SendResponse(CyhookHandler *hh); virtual THandleStatus Hook_ReadConfig(CConfigFile *Config, CStringList &ConfigList); From 084e2b12b09d09dd8b72ddc9827dbd6effcdbcce Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 6 Sep 2017 15:22:44 +0200 Subject: [PATCH 34/40] nhttpd: remove unused string Dbox_Hersteller Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/e4b09ad9c7bb0ce0248126941ba0cc357628d27d Author: vanhofen Date: 2017-09-06 (Wed, 06 Sep 2017) Origin message was: ------------------ - nhttpd: remove unused string Dbox_Hersteller ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/neutrinoapi.cpp | 1 - src/nhttpd/tuxboxapi/neutrinoapi.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/neutrinoapi.cpp index 52487db97..001199094 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoapi.cpp @@ -102,7 +102,6 @@ const char * _getISO639Description(const char * const iso) //============================================================================= // Initialization of static variables //============================================================================= -std::string CNeutrinoAPI::Dbox_Hersteller[4] = {"none", "Nokia", "Philips", "Sagem"}; std::string CNeutrinoAPI::videooutput_names[5] = {"CVBS", "RGB with CVBS", "S-Video", "YUV with VBS", "YUV with CVBS"}; std::string CNeutrinoAPI::videoformat_names[5] = {"automatic", "4:3", "14:9", "16:9", "20:9"}; std::string CNeutrinoAPI::audiotype_names[5] = {"none", "single channel","dual channel","joint stereo","stereo"}; diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.h b/src/nhttpd/tuxboxapi/neutrinoapi.h index 77e51baa0..44c6d8b4a 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.h +++ b/src/nhttpd/tuxboxapi/neutrinoapi.h @@ -49,7 +49,6 @@ public: //bool standby_mode; // some constants - static std::string Dbox_Hersteller[4]; static std::string videooutput_names[5]; static std::string videoformat_names[5]; static std::string audiotype_names[5]; From b74c372d6e6dc5827f2540ca5f49f56935cd80f5 Mon Sep 17 00:00:00 2001 From: gixxpunk Date: Wed, 6 Sep 2017 17:25:08 +0200 Subject: [PATCH 35/40] fix name/path of mdev mount script in neutrino Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/812ef8711990bbb1d45adb1a550c42e429d7c9a2 Author: gixxpunk Date: 2017-09-06 (Wed, 06 Sep 2017) Origin message was: ------------------ - fix name/path of mdev mount script in neutrino ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/hdd_menu.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 943e0284d..8ffb65845 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -63,11 +63,7 @@ #define EJECT_BIN "/bin/eject" //NI -#ifdef BOXMODEL_CS_HD2 -#define MDEV_MOUNT "/lib/mdev/fs/mount" -#else -#define MDEV_MOUNT "/etc/mdev/mdev-mount.sh" -#endif +#define MDEV_MOUNT "/lib/mdev/fs/mdev-mount" #define MOUNT_BASE "/media/" #define HDD_NOISE_OPTION_COUNT 4 From 061a6e7c6a92511679b1e2f3103eb62c7591770b Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 7 Sep 2017 16:18:30 +0200 Subject: [PATCH 36/40] menu: always add an offset to menus; not only in round-border-mode Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/65b8a7ae48c09378f08f6cae2c59ba9449e99623 Author: vanhofen Date: 2017-09-07 (Thu, 07 Sep 2017) Origin message was: ------------------ - menu: always add an offset to menus; not only in round-border-mode ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/menue.cpp | 61 +- src/gui/widget/menue.cpp.orig | 2480 +++++++++++++++++++++++++++++++++ src/gui/widget/menue.h | 2 +- 3 files changed, 2515 insertions(+), 28 deletions(-) create mode 100644 src/gui/widget/menue.cpp.orig diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 90cfeb631..d5f04d329 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -277,7 +277,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text right_bg_col = COL_MENUCONTENTINACTIVE_TEXT; right_frame_col = COL_MENUCONTENTINACTIVE_TEXT; } - CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, NULL, false, right_frame_col, right_bg_col); + CComponentsShapeSquare col(stringstartposOption, y + OFFSET_INNER_SMALL, dx - stringstartposOption + x - OFFSET_INNER_MID, item_height - 2*OFFSET_INNER_SMALL, NULL, false, right_frame_col, right_bg_col); col.setFrameThickness(1); //NI col.setCorner(RADIUS_SMALL); col.paint(false); @@ -582,7 +582,7 @@ void CMenuWidget::Init(const std::string &NameString, const std::string &Icon, c offx = offy = 0; from_wizard = SNeutrinoSettings::WIZARD_OFF; fade = true; - sb_width = 0; + scrollbar_width = 0; savescreen = false; preselected = -1; nextShortcut = 1; @@ -1093,7 +1093,7 @@ void CMenuWidget::hide() info_box->kill(); if (details_line) details_line->hide(); - frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height + fbutton_height); + frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height); //paintHint(-1); } paintHint(-1); @@ -1164,10 +1164,10 @@ void CMenuWidget::calcSize() } /* set the max height to 9/10 of usable screen height debatable, if the callers need a possibility to set this */ - height = (frameBuffer->getScreenHeight() - fbutton_height - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ + height = (frameBuffer->getScreenHeight() - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ - if(height > ((int)frameBuffer->getScreenHeight() - OFFSET_INNER_MID)) - height = frameBuffer->getScreenHeight() - OFFSET_INNER_MID; + if (height > ((int)frameBuffer->getScreenHeight() - 2*OFFSET_INNER_MID)) + height = frameBuffer->getScreenHeight() - 2*OFFSET_INNER_MID; int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(getName()); if (neededWidth > width - frameBuffer->scale2Res(48)) { @@ -1216,14 +1216,21 @@ void CMenuWidget::calcSize() // shrink menu if less items height = std::min(height, hheight + maxItemHeight); + /* + Always add a bottom offset. + Most menus has an upper offset too, + which is added with the intro-items + */ + height += OFFSET_INNER_MID; //scrollbar width - sb_width=0; - if(total_pages > 1) - sb_width=SCROLLBAR_WIDTH; + scrollbar_width=0; + if (total_pages > 1) + scrollbar_width = scrollbar_width; + + full_width = width + scrollbar_width + OFFSET_SHADOW; + full_height = height + fbutton_height + OFFSET_SHADOW + OFFSET_INTER; // hintbox is handled separately - full_width = /*DETAILSLINE_WIDTH+*/width+sb_width+OFFSET_SHADOW; - full_height = height+RADIUS_LARGE+OFFSET_SHADOW*2 /*+hint_height+OFFSET_INTER*/; /* + DETAILSLINE_WIDTH for the hintbox connection line * + center_offset for symmetry * + 20 for setMenuPos calculates 10 pixels border left and right */ @@ -1231,7 +1238,7 @@ void CMenuWidget::calcSize() int max_possible = (int)frameBuffer->getScreenWidth() - DETAILSLINE_WIDTH - center_offset - 2*OFFSET_INNER_MID; if (full_width > max_possible) { - width = max_possible - sb_width - OFFSET_SHADOW; + width = max_possible - scrollbar_width - OFFSET_SHADOW; full_width = max_possible + center_offset; /* symmetry in MENU_POS_CENTER case */ } @@ -1270,7 +1277,7 @@ void CMenuWidget::paint() // paint head if (header == NULL){ - header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile); + header = new CComponentsHeader(x, y, width + scrollbar_width, hheight, getName(), iconfile); header->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT); header->setOffset(OFFSET_INNER_MID); } @@ -1281,16 +1288,16 @@ void CMenuWidget::paint() header->enableGradientBgCleanUp(savescreen); header->paint(CC_SAVE_SCREEN_NO); - // paint body shadow - frameBuffer->paintBoxRel(x+OFFSET_SHADOW, y + hheight + OFFSET_SHADOW, width + sb_width, height - hheight + RADIUS_LARGE + (fbutton_count ? fbutton_height : 0), COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + // paint body and footer shadow + frameBuffer->paintBoxRel(x + OFFSET_SHADOW, y + hheight + OFFSET_SHADOW, width + scrollbar_width, height - hheight + fbutton_height, COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); // paint body background - frameBuffer->paintBoxRel(x, y+hheight, width + sb_width, height-hheight + RADIUS_LARGE, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, (fbutton_count ? CORNER_NONE : CORNER_BOTTOM)); + frameBuffer->paintBoxRel(x, y + hheight, width + scrollbar_width, height - hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, (fbutton_count ? CORNER_NONE : CORNER_BOTTOM)); item_start_y = y+hheight; paintItems(); washidden = false; if (fbutton_count) - ::paintButtons(x, y + height + RADIUS_LARGE, width + sb_width, fbutton_count, fbutton_labels, width, fbutton_height); + ::paintButtons(x, y + height, width + scrollbar_width, fbutton_count, fbutton_labels, width, fbutton_height); } void CMenuWidget::setMenuPos(const int& menu_width) @@ -1299,7 +1306,7 @@ void CMenuWidget::setMenuPos(const int& menu_width) int scr_y = frameBuffer->getScreenY(); int scr_w = frameBuffer->getScreenWidth(); int scr_h = frameBuffer->getScreenHeight(); - int real_h = full_height + fbutton_height + hint_height; + int real_h = full_height + hint_height; int x_old = x; int y_old = y; //configured positions @@ -1351,11 +1358,11 @@ void CMenuWidget::paintItems() // Scrollbar if(total_pages>1) { - int item_height=height-(item_start_y-y); - paintScrollBar(x+ width, item_start_y, sb_width, item_height, total_pages, current_page); + int scrollbar_height = height - hheight - OFFSET_INNER_MID; + paintScrollBar(x + width, item_start_y, scrollbar_width, scrollbar_height, total_pages, current_page); /* background of menu items, paint every time because different items can have * different height and this might leave artifacts otherwise after changing pages */ - frameBuffer->paintBoxRel(x,item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0); + frameBuffer->paintBoxRel(x, item_start_y, width, scrollbar_height, COL_MENUCONTENT_PLUS_0); } int ypos=item_start_y; @@ -1419,7 +1426,7 @@ void CMenuWidget::saveScreen() return; delete[] background; - saveScreen_height = full_height+fbutton_height; + saveScreen_height = full_height; saveScreen_width = full_width; saveScreen_y = y; saveScreen_x = x; @@ -1488,15 +1495,15 @@ void CMenuWidget::paintHint(int pos) item->hintText = " "; int iheight = item->getHeight(); - int rad = RADIUS_LARGE; int xpos = x - DETAILSLINE_WIDTH; - int ypos2 = y + height + fbutton_height + rad + OFFSET_SHADOW + OFFSET_INTER; - int iwidth = width+sb_width; + int ypos2 = y + full_height; + int iwidth = width + scrollbar_width; //init details line and infobox dimensions int ypos1 = item->getYPosition(); int ypos1a = ypos1 + (iheight/2); int ypos2a = ypos2 + (hint_height/2); + int rad = RADIUS_LARGE; int markh = hint_height > rad*2 ? hint_height - rad*2 : hint_height; int imarkh = iheight/2; @@ -1520,7 +1527,7 @@ void CMenuWidget::paintHint(int pos) info_box->setFrameThickness(g_settings.show_menu_hints_line ? 1 : 0); //NI //NI info_box->removeLineBreaks(str); info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT); - info_box->setCorner(RADIUS_LARGE); + info_box->setCorner(rad); info_box->setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENTDARK_PLUS_0); info_box->setTextColor(COL_MENUCONTENTDARK_TEXT); info_box->enableShadow(); @@ -2312,7 +2319,7 @@ int CMenuSeparator::paint(bool selected) item_bgcolor = COL_MENUCONTENT_PLUS_0; } - frameBuffer->paintBoxRel(x,y, dx, height, item_bgcolor); + frameBuffer->paintBoxRel(x, y, dx, height, item_bgcolor); if ((type & LINE)) { int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF; diff --git a/src/gui/widget/menue.cpp.orig b/src/gui/widget/menue.cpp.orig new file mode 100644 index 000000000..90cfeb631 --- /dev/null +++ b/src/gui/widget/menue.cpp.orig @@ -0,0 +1,2480 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2001 Steffen Hehn 'McClean' + Homepage: http://dbox.cyberphoria.org/ + + (C) 2008, 2009 Stefan Seyfried + Copyright (C) 2012 CoolStream International Ltd + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + + +#include +#include +#include + +#include +#include +#include +#include +#include + + +#include +#include +#include + +#include + +//NI lcd4l-support +#include "gui/lcd4l.h" +extern CLCD4l *LCD4l; + +/* the following generic menu items are integrated into multiple menus at the same time */ +CMenuSeparator CGenericMenuSeparator(0, NONEXISTANT_LOCALE, true); +CMenuSeparator CGenericMenuSeparatorLine(CMenuSeparator::LINE, NONEXISTANT_LOCALE, true); +CMenuForwarder CGenericMenuBack(LOCALE_MENU_BACK, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_LEFT, NULL, true); +CMenuForwarder CGenericMenuCancel(LOCALE_MENU_CANCEL, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME, NULL, true); +CMenuForwarder CGenericMenuNext(LOCALE_MENU_NEXT, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_RIGHT, NULL, true); +CMenuSeparator * const GenericMenuSeparator = &CGenericMenuSeparator; +CMenuSeparator * const GenericMenuSeparatorLine = &CGenericMenuSeparatorLine; +CMenuForwarder * const GenericMenuBack = &CGenericMenuBack; +CMenuForwarder * const GenericMenuCancel = &CGenericMenuCancel; +CMenuForwarder * const GenericMenuNext = &CGenericMenuNext; + +CMenuItem::CMenuItem(bool Active, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) +{ + active = current_active = Active; + directKey = DirectKey; + isStatic = IsStatic; + + if (IconName && *IconName) + iconName = IconName; + else + setIconName(); + + if (IconName_Info_right && *IconName_Info_right) + iconName_Info_right = IconName_Info_right; + else + iconName_Info_right = NULL; + + hintIcon = NULL; + + x = -1; + used = false; + icon_frame_w = OFFSET_INNER_MID; + hint = NONEXISTANT_LOCALE; + name = NONEXISTANT_LOCALE; + nameString = ""; + desc = NONEXISTANT_LOCALE; + descString = ""; + marked = false; + inert = false; + directKeyOK = true; + selected_iconName = NULL; + height = 0; + actObserv = NULL; + parent_widget = NULL; + + lcd4l_text = ""; //NI lcd4l-support +} + +void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX) +{ + x = X; + y = Y; + dx = DX; + offx = OFFX; + name_start_x = x + offx + icon_frame_w; + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_0; +} + +void CMenuItem::setActive(const bool Active) +{ + active = current_active = Active; + /* used gets set by the addItem() function. This is for disabling + machine-specific options by just not calling the addItem() function. + Without this, the changeNotifiers would become machine-dependent. */ + if (used && x != -1) + paint(); +} + +bool CMenuItem::initModeCondition(const int& stb_mode) +{ + if (CNeutrinoApp::getInstance()->getMode() == stb_mode){ + active = false; + marked = false; + if (parent_widget) + if (!isSelectable()) + parent_widget->initSelectable(); + return true; + } + printf("\033[33m[CMenuItem] [%s - %d] missmatching stb mode condition %d\033[0m\n", __func__, __LINE__, stb_mode); + return false; +} + +void CMenuItem::disableByCondition(const menu_item_disable_cond_t& condition) +{ + int stb_mode = CNeutrinoApp::getInstance()->getMode(); + + if (condition & DCOND_MODE_TS){ + if (stb_mode == CNeutrinoApp::mode_ts) + if (initModeCondition(stb_mode)) + return; + } + if (condition & DCOND_MODE_RADIO){ + if (stb_mode == CNeutrinoApp::mode_radio) + if (initModeCondition(stb_mode)) + return; + } + if (condition & DCOND_MODE_TV){ + if (stb_mode == CNeutrinoApp::mode_tv) + if (initModeCondition(stb_mode)) + return; + } + + active = current_active; + + if (parent_widget){ + if (!isSelectable()) + parent_widget->initSelectable(); + } +} + +void CMenuItem::setMarked(const bool Marked) +{ + marked = Marked; + if (used && x != -1) + paint(); +} + +void CMenuItem::setInert(const bool Inert) +{ + inert = Inert; + if (used && x != -1) + paint(); +} + +void CMenuItem::setItemButton(const char * const icon_Name, const bool is_select_button) +{ + if (is_select_button) + selected_iconName = icon_Name; + else + iconName = icon_Name; +} + +void CMenuItem::initItemColors(const bool select_mode) +{ + if (select_mode) + { + item_color = COL_MENUCONTENTSELECTED_TEXT; + item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; + } + else if (!active || inert) + { + item_color = COL_MENUCONTENTINACTIVE_TEXT; + item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; + } + else if (marked) + { + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_1; + } + else + { + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_0; + } +} + +void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text, const fb_pixel_t right_bgcol) +{ + int item_height = height; + const char *left_text = getName(); + const char *desc_text = getDescription(); + + if (select_mode) + { + if (right_text && *right_text) + { + ssize_t len = strlen(left_text) + strlen(right_text) + 2; + char str[len]; + snprintf(str, len, "%s %s", left_text, right_text); + CVFD::getInstance()->showMenuText(0, str, -1, true); + //NI lcd4l-support + if(g_settings.lcd4l_support) + lcd4l_text = str; + } + else + { + CVFD::getInstance()->showMenuText(0, left_text, -1, true); + //NI lcd4l-support + if (g_settings.lcd4l_support) + lcd4l_text = left_text; + } + + //NI lcd4l-support + if (g_settings.lcd4l_support) + LCD4l->CreateFile("/tmp/lcd/menu", lcd4l_text, g_settings.lcd4l_convert); + } + + //left text + int _dx = dx; + int icon_w = 0; + int icon_h = 0; + if (iconName_Info_right) { + CFrameBuffer::getInstance()->getIconSize(iconName_Info_right, &icon_w, &icon_h); + if (icon_w) + _dx -= icon_frame_w + icon_w; + } + + int desc_height = 0; + if (desc_text && *desc_text) + desc_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); + + if (*left_text) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height - desc_height, _dx- (name_start_x - x), left_text, item_color); + + //right text + if (right_text && (*right_text || right_bgcol)) + { + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text); + int stringstartposOption; + if (*left_text) + stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx + else + stringstartposOption = name_start_x; + if (right_bgcol) { + if (!*right_text) + stringstartposOption -= CFrameBuffer::getInstance()->scale2Res(60); + fb_pixel_t right_frame_col, right_bg_col; + if (active) { + right_bg_col = right_bgcol; + right_frame_col = COL_FRAME_PLUS_0; + } + else { + right_bg_col = COL_MENUCONTENTINACTIVE_TEXT; + right_frame_col = COL_MENUCONTENTINACTIVE_TEXT; + } + CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, NULL, false, right_frame_col, right_bg_col); + col.setFrameThickness(1); //NI + col.setCorner(RADIUS_SMALL); + col.paint(false); + } + if (*right_text) { + stringstartposOption -= (icon_w == 0 ? 0 : icon_w + icon_frame_w); + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height - desc_height, dx- (stringstartposOption- x), right_text, item_color); + } + } + if (desc_text && *desc_text) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->RenderString(name_start_x + OFFSET_INNER_MID, y+ item_height, _dx- OFFSET_INNER_MID - (name_start_x - x), desc_text, item_color); +} + +void CMenuItem::prepareItem(const bool select_mode, const int &item_height) +{ + //set colors + initItemColors(select_mode); + + //paint item background + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + frameBuffer->paintBoxRel(x, y, dx, item_height, item_bgcolor, RADIUS_LARGE); +} + +void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text, const char * right_text) +{ + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + int slider_lenght = 0, h = 0; + frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMEBODY, &slider_lenght, &h); + if(slider_lenght == 0 || factor < optionvalue ) + return; + int stringwidth = 0; + if (right_text != NULL) { + stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999"); + } + int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text); + + int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - OFFSET_INNER_MID; + if(maxspace < slider_lenght) + return ; + + int stringstartposOption = x + dx - stringwidth - slider_lenght; + int optionV = (optionvalue < 0) ? 0 : optionvalue; + frameBuffer->paintBoxRel(stringstartposOption, y, slider_lenght, item_height, item_bgcolor); + frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY, stringstartposOption, y+2+item_height/4); + frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2BLUE : NEUTRINO_ICON_VOLUMESLIDER2, (stringstartposOption + (optionV * 100 / factor)), y+item_height/4); +} + +void CMenuItem::paintItemButton(const bool select_mode, int item_height, const char * const icon_Name) +{ + item_height -= getDescriptionHeight(); + + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + bool selected = select_mode; + bool icon_painted = false; + + const char *icon_name = iconName; + int icon_w = 0; + int icon_h = 0; + + //define icon name depends of numeric value + bool isNumeric = CRCInput::isNumeric(directKey); +#if 0 + if (isNumeric && !g_settings.menu_numbers_as_icons) + icon_name = NULL; +#endif + //define select icon + if (selected && offx > 0) + { + if (selected_iconName) + icon_name = selected_iconName; + else if (!(icon_name && *icon_name) && !isNumeric) + icon_name = icon_Name; + } + + int icon_start_x = x+icon_frame_w; //start of icon space + int icon_space_x = name_start_x - icon_frame_w - icon_start_x; //size of space where to paint icon + int icon_space_mid = icon_start_x + icon_space_x/2; + + //get data of number icon and paint + if (icon_name && *icon_name) + { + if (!active) + icon_name = NEUTRINO_ICON_BUTTON_DUMMY_SMALL; + + frameBuffer->getIconSize(icon_name, &icon_w, &icon_h); + + if (/*active &&*/ icon_w>0 && icon_h>0 && icon_space_x >= icon_w) + { + int icon_x = icon_space_mid - icon_w/2; + int icon_y = y + item_height/2 - icon_h/2; + icon_painted = frameBuffer->paintIcon(icon_name, icon_x, icon_y); + if (icon_painted && (directKey != CRCInput::RC_nokey) && (directKey & CRCInput::RC_Repeat)) { + static int longpress_icon_w = 0, longpress_icon_h = 0; + if (!longpress_icon_w) + frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_LONGPRESS, &longpress_icon_w, &longpress_icon_h); + frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_LONGPRESS, + std::min(icon_x + icon_w - longpress_icon_w/2, name_start_x - longpress_icon_w), + std::min(icon_y + icon_h - longpress_icon_h/2, y + item_height - longpress_icon_h)); + } + } + } + + //paint only number if no icon was painted and keyval is numeric + if (active && isNumeric && !icon_painted) + { + int number_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(CRCInput::getKeyName(directKey)); + + int number_x = icon_space_mid - (number_w/2); + + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(number_x, y+ item_height, item_height, CRCInput::getKeyName(directKey), item_color, item_height); + } + + //get data of number right info icon and paint + if (iconName_Info_right) + { + frameBuffer->getIconSize(iconName_Info_right, &icon_w, &icon_h); + + if (icon_w>0 && icon_h>0) + { + frameBuffer->paintIcon(iconName_Info_right, dx + icon_start_x - (icon_w + 2*OFFSET_INNER_MID), y+ ((item_height/2- icon_h/2)) ); + } + } +} + +void CMenuItem::setIconName() +{ + iconName = NULL; + + switch (directKey & ~CRCInput::RC_Repeat) { + case CRCInput::RC_red: + iconName = NEUTRINO_ICON_BUTTON_RED; + break; + case CRCInput::RC_green: + iconName = NEUTRINO_ICON_BUTTON_GREEN; + break; + case CRCInput::RC_yellow: + iconName = NEUTRINO_ICON_BUTTON_YELLOW; + break; + case CRCInput::RC_blue: + iconName = NEUTRINO_ICON_BUTTON_BLUE; + break; + case CRCInput::RC_standby: + iconName = NEUTRINO_ICON_BUTTON_POWER; + break; + case CRCInput::RC_setup: + iconName = NEUTRINO_ICON_BUTTON_MENU_SMALL; + break; + case CRCInput::RC_help: + iconName = NEUTRINO_ICON_BUTTON_HELP_SMALL; + break; + case CRCInput::RC_info: + iconName = NEUTRINO_ICON_BUTTON_INFO_SMALL; + break; + case CRCInput::RC_pause: //NI + iconName = NEUTRINO_ICON_BUTTON_PAUSE; + break; + case CRCInput::RC_stop: + iconName = NEUTRINO_ICON_BUTTON_STOP; + break; + case CRCInput::RC_0: + iconName = NEUTRINO_ICON_BUTTON_0; + break; + case CRCInput::RC_1: + iconName = NEUTRINO_ICON_BUTTON_1; + break; + case CRCInput::RC_2: + iconName = NEUTRINO_ICON_BUTTON_2; + break; + case CRCInput::RC_3: + iconName = NEUTRINO_ICON_BUTTON_3; + break; + case CRCInput::RC_4: + iconName = NEUTRINO_ICON_BUTTON_4; + break; + case CRCInput::RC_5: + iconName = NEUTRINO_ICON_BUTTON_5; + break; + case CRCInput::RC_6: + iconName = NEUTRINO_ICON_BUTTON_6; + break; + case CRCInput::RC_7: + iconName = NEUTRINO_ICON_BUTTON_7; + break; + case CRCInput::RC_8: + iconName = NEUTRINO_ICON_BUTTON_8; + break; + case CRCInput::RC_9: + iconName = NEUTRINO_ICON_BUTTON_9; + break; + } +} + +void CMenuItem::setName(const std::string& t) +{ + name = NONEXISTANT_LOCALE; + nameString = t; +} + +void CMenuItem::setName(const neutrino_locale_t t) +{ + name = t; + nameString = ""; +} + +const char *CMenuItem::getName(void) +{ + if (name != NONEXISTANT_LOCALE) + return g_Locale->getText(name); + return nameString.c_str(); +} + +void CMenuItem::setDescription(const std::string& t) +{ + desc = NONEXISTANT_LOCALE; + descString = t; + getHeight(); +} + +void CMenuItem::setDescription(const neutrino_locale_t t) +{ + desc = t; + descString = ""; + getHeight(); +} + +const char *CMenuItem::getDescription(void) +{ + if (desc != NONEXISTANT_LOCALE) + return g_Locale->getText(desc); + return descString.c_str(); +} + +int CMenuItem::getDescriptionHeight(void) +{ + if (*getDescription()) + return g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); + return 0; +} + +int CMenuItem::getHeight(void) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + getDescriptionHeight(); + return height; +} + +void CMenuItem::activateNotify() +{ + if (actObserv) + actObserv->activateNotify(name); +} + +//small helper class to manage values e.g.: handling needed but deallocated widget objects +CMenuGlobal::CMenuGlobal() +{ + //creates needed select values with default value NO_WIDGET_ID = -1 + for (uint i=0; igetText(Name), Icon, mwidth, w_index); +} + +CMenuWidget::CMenuWidget(const std::string &Name, const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) +{ + Init(Name, Icon, mwidth, w_index); +} + +void CMenuWidget::Init(const std::string &NameString, const std::string &Icon, const int mwidth, const mn_widget_id_t &w_index) +{ + //pos + x = y = 0; + + //caption and icon + nameString = NameString; + iconfile = Icon; + + //basic attributes + iconOffset = 0; + offx = offy = 0; + from_wizard = SNeutrinoSettings::WIZARD_OFF; + fade = true; + sb_width = 0; + savescreen = false; + preselected = -1; + nextShortcut = 1; + current_page = 0; + has_hints = false; + brief_hints = BRIEF_HINT_NO; + hint_painted = false; + hint_height = 0; + fbutton_count = 0; + fbutton_labels = NULL; + fbutton_width = 0; + fbutton_height = 0; + saveScreen_width = 0; + saveScreen_height = 0; + + //objects + background = NULL; + details_line = NULL; + info_box = NULL; + header = NULL; + frameBuffer = CFrameBuffer::getInstance(); + mglobal = CMenuGlobal::getInstance(); //create CMenuGlobal instance only here + + //handle select values + if(w_index > MN_WIDGET_ID_MAX){ + //error + fprintf(stderr, "Warning: %s Index ID value (%i) is bigger than MN_WIDGET_ID_MAX (%i) \n", __FUNCTION__,w_index,MN_WIDGET_ID_MAX ); + widget_index = NO_WIDGET_ID; + } + else{ + //ok + widget_index = w_index; + } + + //overwrite preselected value with global select value + selected = (widget_index == NO_WIDGET_ID ? preselected : mglobal->v_selected[widget_index]); + + //dimension + mwidth_save = mwidth; + min_width = 0; + width = 0; /* is set in paint() */ + if (mwidth > 100){ + /* warn about abuse until we found all offenders... */ + fprintf(stderr, "Warning: %s (%s) (%s) mwidth over 100%%: %d\n", __FUNCTION__, nameString.c_str(), Icon.c_str(), mwidth); + } + else{ + min_width = frameBuffer->getScreenWidth(true) * mwidth / 100; + if(min_width > (int) frameBuffer->getScreenWidth()) + min_width = frameBuffer->getScreenWidth(); + } +} + +void CMenuWidget::move(int xoff, int yoff) +{ + offx = xoff; + offy = yoff; +} + +CMenuWidget::~CMenuWidget() +{ + resetWidget(true); + ResetModules(); +} + +void CMenuWidget::ResetModules() +{ + if (header){ + header->hide(); + delete header; + header = NULL; + } + if (details_line){ + details_line->hide(); + delete details_line; + details_line = NULL; + } + if (info_box){ + info_box->kill(); + delete info_box; + info_box = NULL; + } +} + +void CMenuWidget::addItem(CMenuItem* menuItem, const bool defaultselected) +{ + if (menuItem->isSelectable()) + { + bool isSelected = defaultselected; + + if (preselected != -1) + isSelected = (preselected == (int)items.size()); + + if (isSelected) + selected = items.size(); + } + + menuItem->isUsed(); + items.push_back(menuItem); + menuItem->setParentWidget(this); +} + +void CMenuWidget::resetWidget(bool delete_items) +{ + for(unsigned int count=0;countisStatic){ + delete item; + item = NULL; + } + } + + items.clear(); + page_start.clear(); + selected=-1; +} + +void CMenuWidget::insertItem(const uint& item_id, CMenuItem* menuItem) +{ + items.insert(items.begin()+item_id, menuItem); +} + +void CMenuWidget::removeItem(const uint& item_id) +{ + items.erase(items.begin()+item_id); + if ((unsigned int) selected >= items.size()) + selected = items.size() - 1; + while (selected > 0 && !items[selected]->active) + selected--; +} + +bool CMenuWidget::hasItem() +{ + return !items.empty(); +} + +int CMenuWidget::getItemId(CMenuItem* menuItem) +{ + for (uint i= 0; i< items.size(); i++) + if (items[i] == menuItem) + return i; + return -1; +} + +CMenuItem* CMenuWidget::getItem(const uint& item_id) +{ + for (uint i= 0; i< items.size(); i++) + if (i == item_id) + return items[i]; + return NULL; +} + +const char *CMenuWidget::getName() +{ + return nameString.c_str(); +} + +int CMenuWidget::exec(CMenuTarget* parent, const std::string &) +{ + neutrino_msg_t msg; + neutrino_msg_data_t data; + bool bAllowRepeatLR = false; + CVFD::MODES oldLcdMode = CVFD::getInstance()->getMode(); + + exit_pressed = false; + + frameBuffer->Lock(); + + if (parent) + parent->hide(); + + COSDFader fader(g_settings.theme.menu_Content_alpha); + if(fade) + fader.StartFadeIn(); + + if(from_wizard) { + for (unsigned int count = 0; count < items.size(); count++) { + if(items[count] == GenericMenuBack) { + items[count] = GenericMenuNext; + break; + } + } + } + + checkHints(); + + if(savescreen) { + calcSize(); + saveScreen(); + } + + /* make sure we start with a selectable item... */ + initSelectable(); + + paint(); + frameBuffer->blit(); + + int pos = selected; + + int retval = menu_return::RETURN_REPAINT; + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); + + bool bAllowRepeatLR_override = keyActionMap.find(CRCInput::RC_left) != keyActionMap.end() || keyActionMap.find(CRCInput::RC_right) != keyActionMap.end(); + do { + if(hasItem() && selected >= 0 && (int)items.size() > selected ) + bAllowRepeatLR = items[selected]->isMenueOptionChooser(); + bAllowRepeatLR |= bAllowRepeatLR_override; + + g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, bAllowRepeatLR); + + int handled= false; + if ( msg <= CRCInput::RC_MaxRC ) { + timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); + + std::map::iterator it = keyActionMap.find(msg); + if (it != keyActionMap.end()) { + fader.StopFade(); + int rv = it->second.menue->exec(this, it->second.action); + switch ( rv ) { + case menu_return::RETURN_EXIT_ALL: + retval = menu_return::RETURN_EXIT_ALL; + case menu_return::RETURN_EXIT: + msg = CRCInput::RC_timeout; + break; + case menu_return::RETURN_REPAINT: + case menu_return::RETURN_EXIT_REPAINT: + if (fade && washidden) + fader.StartFadeIn(); + checkHints(); + paint(); + break; + } + frameBuffer->blit(); + continue; + } + for (unsigned int i= 0; i< items.size(); i++) { + CMenuItem* titem = items[i]; + if ((titem->directKey != CRCInput::RC_nokey) && (titem->directKey == msg)) { + if (titem->isSelectable()) { + items[selected]->paint( false ); + selected= i; + if (selected > page_start[current_page + 1] || selected < page_start[current_page]) { + /* different page */ + paintItems(); + } + paintHint(selected); + pos = selected; + if (titem->directKeyOK) + msg = CRCInput::RC_ok; + else + msg = CRCInput::RC_nokey; + } else { + // swallow-key... + handled= true; + } + break; + } + } +#if 0 + if (msg == (uint32_t) g_settings.key_pageup) + msg = CRCInput::RC_page_up; + else if (msg == (uint32_t) g_settings.key_pagedown) + msg = CRCInput::RC_page_down; +#endif + } + + if (handled) + continue; + + switch (msg) { + case (NeutrinoMessages::EVT_TIMER): + if(data == fader.GetFadeTimer()) { + if(fader.FadeDone()) + msg = CRCInput::RC_timeout; + } else { + if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { + retval = menu_return::RETURN_EXIT_ALL; + msg = CRCInput::RC_timeout; + } + } + break; + case CRCInput::RC_page_up: + case CRCInput::RC_page_down: + case CRCInput::RC_up: + case CRCInput::RC_down: + case CRCInput::RC_nokey: + { + /* dir and wrap are used when searching for a selectable item: + * if the item is not selectable, try the previous (dir = -1) or + * next (dir = 1) item, until a selectale item is found. + * if wrap = true, allows to wrap around while searching */ + int dir = 1; + bool wrap = false; + switch (msg) { + case CRCInput::RC_nokey: + break; + case CRCInput::RC_page_up: + if (current_page) { + pos = page_start[current_page] - 1; + dir = -1; /* pg_up: search upwards */ + } else + pos = 0; /* ...but not if already at top */ + break; + case CRCInput::RC_page_down: + pos = page_start[current_page + 1]; + if (pos >= (int)items.size()) { + pos = items.size() - 1; + dir = -1; /* if last item is not selectable, go up */ + } + break; + case CRCInput::RC_up: + dir = -1; + default: /* fallthrough or RC_down => dir = 1 */ + pos += dir; + if (pos < 0 || pos >= (int)items.size()) + pos -= dir * items.size(); + wrap = true; + } + if (!items.empty() && pos >= (int)items.size()) + pos = (int)items.size() - 1; + do { + if(items.empty()) + break; + CMenuItem* item = items[pos]; + if (item->isSelectable()) { + if (pos < page_start[current_page + 1] && pos >= page_start[current_page]) { + /* in current page */ + items[selected]->paint(false); + item->activateNotify(); + item->paint(true); + paintHint(pos); + selected = pos; + } else { + /* different page */ + selected = pos; + paintItems(); + } + break; + } + pos += dir; + if (wrap && (pos >= (int)items.size() || pos < 0)) { + pos -= dir * items.size(); + wrap = false; /* wrap only once, avoids endless loop */ + } + } while (pos >= 0 && pos < (int)items.size()); + break; + } + case (CRCInput::RC_left): + { + if(hasItem() && selected > -1 && (int)items.size() > selected) { + CMenuItem* itemX = items[selected]; + if (!itemX->isMenueOptionChooser()) { + if (g_settings.menu_left_exit) + msg = CRCInput::RC_timeout; + break; + } + } + } + case (CRCInput::RC_right): + case (CRCInput::RC_ok): + { + if(hasItem() && selected > -1 && (int)items.size() > selected) { + //NI lcd4l-support + LCD4l->RemoveFile("/tmp/lcd/menu"); + + //exec this item... + CMenuItem* item = items[selected]; + if (!item->isSelectable()) + break; + item->msg = msg; + fader.StopFade(); + int rv = item->exec( this ); + + //NI lcd4l-support + if (g_settings.lcd4l_support) + LCD4l->CreateFile("/tmp/lcd/menu", item->lcd4l_text, g_settings.lcd4l_convert); + + switch ( rv ) { + case menu_return::RETURN_EXIT_ALL: + retval = menu_return::RETURN_EXIT_ALL; + case menu_return::RETURN_EXIT: + msg = CRCInput::RC_timeout; + break; + case menu_return::RETURN_REPAINT: + case menu_return::RETURN_EXIT_REPAINT: + if (fade && washidden) + fader.StartFadeIn(); + checkHints(); + pos = selected; + paint(); + break; + } + } else + msg = CRCInput::RC_timeout; + } + break; + + case (CRCInput::RC_home): + exit_pressed = true; + msg = CRCInput::RC_timeout; + break; + case (CRCInput::RC_timeout): + break; + case (CRCInput::RC_setup): + //close any menu on menu-key + { + msg = CRCInput::RC_timeout; + retval = menu_return::RETURN_EXIT_ALL; + } + break; + case (CRCInput::RC_help): + // FIXME should we switch hints in menu without hints ? + checkHints(); + if (has_hints) + hide(); + g_settings.show_menu_hints = !g_settings.show_menu_hints; + if (has_hints) + paint(); + break; + + default: + if (CNeutrinoApp::getInstance()->listModeKey(msg)) { + g_RCInput->postMsg (msg, 0); + retval = menu_return::RETURN_EXIT_ALL; + msg = CRCInput::RC_timeout; + } + else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { + retval = menu_return::RETURN_EXIT_ALL; + msg = CRCInput::RC_timeout; + } + } + if(msg == CRCInput::RC_timeout) { + if(fade && fader.StartFadeOut()) { + timeoutEnd = CRCInput::calcTimeoutEnd( 1 ); + msg = 0; + continue; + } + } + + if ( msg <= CRCInput::RC_MaxRC ) + { + // recalculate timeout for RC-keys + timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); + } + frameBuffer->blit(); + } + while ( msg!=CRCInput::RC_timeout ); + hide(); + if (background) { + delete[] background; + background = NULL; + } + + fader.StopFade(); + + if(!parent) + if(oldLcdMode != CVFD::getInstance()->getMode()) + CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); + + //NI lcd4l-support + LCD4l->RemoveFile("/tmp/lcd/menu"); + + for (unsigned int count = 0; count < items.size(); count++) + { + if(items[count] == GenericMenuNext) + items[count] = GenericMenuBack; + else if (items[count] == GenericMenuCancel) + items[count] = GenericMenuBack; + } + + if (widget_index > -1) + mglobal->v_selected[widget_index] = selected; + + frameBuffer->Unlock(); + return retval; +} + +void CMenuWidget::integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut, bool enabled) +{ + bool separatorline = false; + unsigned int number_of_plugins = (unsigned int) g_Plugins->getNumberOfPlugins(); + unsigned int sc = shortcut; + for (unsigned int count = 0; count < number_of_plugins; count++) + { + if ((g_Plugins->getIntegration(count) == integration) && !g_Plugins->isHidden(count)) + { + if (!separatorline) + { + addItem(GenericMenuSeparatorLine); + separatorline = true; + } + printf("[neutrino] integratePlugins: add %s\n", g_Plugins->getName(count)); + neutrino_msg_t dk = (shortcut != CRCInput::RC_nokey) ? CRCInput::convertDigitToKey(sc++) : CRCInput::RC_nokey; + CMenuForwarder *fw_plugin = new CMenuForwarder(g_Plugins->getName(count), enabled, NULL, CPluginsExec::getInstance(), to_string(count).c_str(), dk); + fw_plugin->setHint(g_Plugins->getHintIcon(count), g_Plugins->getDescription(count)); + addItem(fw_plugin); + } + } +} + +void CMenuWidget::hide() +{ + if(savescreen && background) + restoreScreen();//FIXME + else { + if (header) + header->kill(); + if (info_box) + info_box->kill(); + if (details_line) + details_line->hide(); + frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height + fbutton_height); + //paintHint(-1); + } + paintHint(-1); + frameBuffer->blit(); + + /* setActive() paints item for hidden parent menu, if called from child menu */ + for (unsigned int count = 0; count < items.size(); count++) + items[count]->init(-1, 0, 0, 0); + hint_painted = false; + washidden = true; + if (CInfoClock::getInstance()->isRun()) + CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked()); + OnAfterHide(); +} + +void CMenuWidget::checkHints() +{ + brief_hints = (brief_hints || (from_wizard == SNeutrinoSettings::WIZARD_START)); + + GenericMenuBack->setHint("", NONEXISTANT_LOCALE); + GenericMenuNext->setHint("", NONEXISTANT_LOCALE); + for (unsigned int i= 0; i< items.size(); i++) { + if(items[i]->hintIcon || items[i]->hint != NONEXISTANT_LOCALE || !items[i]->hintText.empty()) { + has_hints = true; + break; + } + } + if (has_hints) { + GenericMenuBack->setHint(NEUTRINO_ICON_HINT_BACK, brief_hints ? LOCALE_MENU_HINT_BACK_BRIEF : LOCALE_MENU_HINT_BACK); + GenericMenuNext->setHint(NEUTRINO_ICON_HINT_NEXT, brief_hints ? LOCALE_MENU_HINT_NEXT_BRIEF : LOCALE_MENU_HINT_NEXT); + } +} + +void CMenuWidget::calcSize() +{ + // recalc min_width + min_width = 0; + int mwidth = std::min(mwidth_save, 100); + min_width = frameBuffer->getScreenWidth(true) * mwidth / 100; + if (min_width > (int)frameBuffer->getScreenWidth()) + min_width = frameBuffer->getScreenWidth(); + + width = min_width; + + int wi, hi; + for (unsigned int i= 0; i< items.size(); i++) { + wi = 0; + if (items[i]->iconName_Info_right) { + frameBuffer->getIconSize(items[i]->iconName_Info_right, &wi, &hi); + if ((wi > 0) && (hi > 0)) + wi += OFFSET_INNER_MID; + else + wi = 0; + } + int tmpw = items[i]->getWidth() + 2*OFFSET_INNER_MID + wi; /* 10 pixels to the left and right of the text */ + if (tmpw > width) + width = tmpw; + } + hint_height = 0; + if(g_settings.show_menu_hints && has_hints) { + int lines = 2; + int text_height = 2*OFFSET_INNER_MID + lines*g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); + /* assuming all hint icons has the same size ! */ + int icon_width, icon_height; + frameBuffer->getIconSize(NEUTRINO_ICON_HINT_TVMODE, &icon_width, &icon_height); + icon_height += 2*OFFSET_INNER_MID; + hint_height = std::max(icon_height, text_height); + } + /* set the max height to 9/10 of usable screen height + debatable, if the callers need a possibility to set this */ + height = (frameBuffer->getScreenHeight() - fbutton_height - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ + + if(height > ((int)frameBuffer->getScreenHeight() - OFFSET_INNER_MID)) + height = frameBuffer->getScreenHeight() - OFFSET_INNER_MID; + + int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(getName()); + if (neededWidth > width - frameBuffer->scale2Res(48)) { + width = neededWidth + frameBuffer->scale2Res(48)+1; + } + hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); + + int heightCurrPage=0; + page_start.clear(); + page_start.push_back(0); + total_pages=1; + + int maxItemHeight = 0; + + for (unsigned int i= 0; i< items.size(); i++) { + int item_height=items[i]->getHeight(); + heightCurrPage+=item_height; + if(heightCurrPage > (height-hheight)) { + page_start.push_back(i); + total_pages++; + maxItemHeight = std::max(heightCurrPage - item_height, maxItemHeight); + heightCurrPage=item_height; + } + } + maxItemHeight = std::max(heightCurrPage, maxItemHeight); + page_start.push_back(items.size()); + + iconOffset= 0; + for (unsigned int i= 0; i< items.size(); i++) + if (items[i]->iconName /*&& !g_settings.menu_numbers_as_icons*/) + { + int w, h; + frameBuffer->getIconSize(items[i]->iconName, &w, &h); + if (w > iconOffset) + iconOffset = w; + } + + iconOffset += OFFSET_INNER_MID; + width += iconOffset; + + if (fbutton_count) + width = std::max(width, fbutton_width); + + if (width > (int)frameBuffer->getScreenWidth()) + width = frameBuffer->getScreenWidth(); + + // shrink menu if less items + height = std::min(height, hheight + maxItemHeight); + + //scrollbar width + sb_width=0; + if(total_pages > 1) + sb_width=SCROLLBAR_WIDTH; + + full_width = /*DETAILSLINE_WIDTH+*/width+sb_width+OFFSET_SHADOW; + full_height = height+RADIUS_LARGE+OFFSET_SHADOW*2 /*+hint_height+OFFSET_INTER*/; + /* + DETAILSLINE_WIDTH for the hintbox connection line + * + center_offset for symmetry + * + 20 for setMenuPos calculates 10 pixels border left and right */ + int center_offset = (g_settings.menu_pos == MENU_POS_CENTER) ? DETAILSLINE_WIDTH : 0; + int max_possible = (int)frameBuffer->getScreenWidth() - DETAILSLINE_WIDTH - center_offset - 2*OFFSET_INNER_MID; + if (full_width > max_possible) + { + width = max_possible - sb_width - OFFSET_SHADOW; + full_width = max_possible + center_offset; /* symmetry in MENU_POS_CENTER case */ + } + + setMenuPos(full_width); +} + +void CMenuWidget::initSelectable() +{ + int pos = 0; + if (selected > 0 && selected < (int)items.size()) + pos = selected; + else + selected = -1; + + while (pos < (int)items.size()) { + if (items[pos]->isSelectable()) + break; + pos++; + } + selected = pos; +} + +void CMenuWidget::paint() +{ + if (header){ + if ((bool)header->getCornerRadius() != (bool)g_settings.rounded_corners) //ensure reset if corner mode was changed + ResetModules(); + } + + if (CInfoClock::getInstance()->isRun()) + CInfoClock::getInstance()->disableInfoClock(); + calcSize(); + CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, nameString.c_str()*/); + + OnBeforePaint(); + + // paint head + if (header == NULL){ + header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile); + header->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT); + header->setOffset(OFFSET_INNER_MID); + } + header->setCaption(getName()); + header->setColorAll(COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0); + header->setCaptionColor(COL_MENUHEAD_TEXT); + header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0); + header->enableGradientBgCleanUp(savescreen); + header->paint(CC_SAVE_SCREEN_NO); + + // paint body shadow + frameBuffer->paintBoxRel(x+OFFSET_SHADOW, y + hheight + OFFSET_SHADOW, width + sb_width, height - hheight + RADIUS_LARGE + (fbutton_count ? fbutton_height : 0), COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + // paint body background + frameBuffer->paintBoxRel(x, y+hheight, width + sb_width, height-hheight + RADIUS_LARGE, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, (fbutton_count ? CORNER_NONE : CORNER_BOTTOM)); + + item_start_y = y+hheight; + paintItems(); + washidden = false; + if (fbutton_count) + ::paintButtons(x, y + height + RADIUS_LARGE, width + sb_width, fbutton_count, fbutton_labels, width, fbutton_height); +} + +void CMenuWidget::setMenuPos(const int& menu_width) +{ + int scr_x = frameBuffer->getScreenX(); + int scr_y = frameBuffer->getScreenY(); + int scr_w = frameBuffer->getScreenWidth(); + int scr_h = frameBuffer->getScreenHeight(); + int real_h = full_height + fbutton_height + hint_height; + int x_old = x; + int y_old = y; + //configured positions + switch(g_settings.menu_pos) + { + case MENU_POS_CENTER: + x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); + y = offy + scr_y + ((scr_h - real_h) >> 1 ); + x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI + break; + + case MENU_POS_TOP_LEFT: + y = offy + scr_y + OFFSET_INNER_MID; + x = offx + scr_x + OFFSET_INNER_MID; + x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI + break; + + case MENU_POS_TOP_RIGHT: + y = offy + scr_y + OFFSET_INNER_MID; + x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; + break; + + case MENU_POS_BOTTOM_LEFT: + y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; + x = offx + scr_x + OFFSET_INNER_MID; + x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI + break; + + case MENU_POS_BOTTOM_RIGHT: + y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; + x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; + break; + } + if (x_old != x || y_old != y) + ResetModules(); +} + +void CMenuWidget::paintItems() +{ + //Item not currently on screen + if (selected >= 0) + { + while (current_page > 0 && selected < page_start[current_page]) + current_page--; + while (current_page+1 < page_start.size() && selected >= page_start[current_page + 1]) + current_page++; + } + + // Scrollbar + if(total_pages>1) + { + int item_height=height-(item_start_y-y); + paintScrollBar(x+ width, item_start_y, sb_width, item_height, total_pages, current_page); + /* background of menu items, paint every time because different items can have + * different height and this might leave artifacts otherwise after changing pages */ + frameBuffer->paintBoxRel(x,item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0); + } + + int ypos=item_start_y; + for (int count = 0; count < (int)items.size(); count++) + { + CMenuItem* item = items[count]; + item->OnPaintItem(); + if ((count >= page_start[current_page]) && + (count < page_start[current_page + 1])) + { + item->init(x, ypos, width, iconOffset); + if (item->isSelectable() && selected == -1) + selected = count; + + if (selected == count) { + item->activateNotify(); + paintHint(count); + } + ypos = item->paint(selected == count); + } + else + { + /* x = -1 is a marker which prevents the item from being painted on setActive changes */ + item->init(-1, 0, 0, 0); + } + } +} + +/*adds the typical menu intro with optional subhead, separator, back or cancel button and separatorline to menu*/ +void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_t section_text, int buttontype, bool brief_hint) +{ + brief_hints = brief_hint; + + if (subhead_text != NONEXISTANT_LOCALE) + addItem(new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING, subhead_text)); + + addItem(GenericMenuSeparator); + + switch (buttontype) { + case BTN_TYPE_BACK: + GenericMenuBack->setItemButton(!g_settings.menu_left_exit ? NEUTRINO_ICON_BUTTON_HOME : NEUTRINO_ICON_BUTTON_LEFT); + addItem(GenericMenuBack); + break; + case BTN_TYPE_CANCEL: + addItem(GenericMenuCancel); + break; + case BTN_TYPE_NEXT: + addItem(GenericMenuNext); + break; + } + + if (section_text != NONEXISTANT_LOCALE) + addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, section_text)); + else if (buttontype != BTN_TYPE_NO) + addItem(GenericMenuSeparatorLine); +} + +void CMenuWidget::saveScreen() +{ + if(!savescreen) + return; + + delete[] background; + saveScreen_height = full_height+fbutton_height; + saveScreen_width = full_width; + saveScreen_y = y; + saveScreen_x = x; + background = new fb_pixel_t [saveScreen_height * saveScreen_width]; + if(background) + frameBuffer->SaveScreen(saveScreen_x /*-DETAILSLINE_WIDTH*/, saveScreen_y, saveScreen_width, saveScreen_height, background); +} + +void CMenuWidget::restoreScreen() +{ + if(background) { + if(savescreen) + frameBuffer->RestoreScreen(saveScreen_x /*-DETAILSLINE_WIDTH*/, saveScreen_y, saveScreen_width, saveScreen_height, background); + } +} + +void CMenuWidget::enableSaveScreen(bool enable) +{ + savescreen = enable; + if (!enable && background) { + delete[] background; + background = NULL; + saveScreen_width = 0; + saveScreen_height = 0; + saveScreen_y = 0; + saveScreen_x = 0; + } +} + +void CMenuWidget::paintHint(int pos) +{ + if (!g_settings.show_menu_hints){ + ResetModules(); //ensure clean up on changed setting + return; + } + + if (pos < 0 && !hint_painted) + return; + + if (hint_painted) { + /* clear detailsline line */ + if (details_line) + details_line->hide(); + /* clear info box */ + if ((info_box) && ((pos < 0) || savescreen)) + savescreen ? info_box->hide() : info_box->kill(); + if (info_box) + hint_painted = info_box->isPainted(); + } + if (pos < 0) + return; + + CMenuItem* item = items[pos]; + + if (!item->hintIcon && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) { + if (info_box) { + savescreen ? info_box->hide() : info_box->kill(); + hint_painted = info_box->isPainted(); + if (details_line) + details_line->hide(); + } + return; + } + + if (item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) + item->hintText = " "; + + int iheight = item->getHeight(); + int rad = RADIUS_LARGE; + int xpos = x - DETAILSLINE_WIDTH; + int ypos2 = y + height + fbutton_height + rad + OFFSET_SHADOW + OFFSET_INTER; + int iwidth = width+sb_width; + + //init details line and infobox dimensions + int ypos1 = item->getYPosition(); + int ypos1a = ypos1 + (iheight/2); + int ypos2a = ypos2 + (hint_height/2); + int markh = hint_height > rad*2 ? hint_height - rad*2 : hint_height; + int imarkh = iheight/2; + + //init details line + if (details_line == NULL) + details_line = new CComponentsDetailsLine(); + + details_line->setXPos(xpos); + details_line->setYPos(ypos1a); + details_line->setYPosDown(ypos2a); + details_line->setHMarkTop(imarkh); + details_line->setHMarkDown(markh); + details_line->syncSysColors(); + + //init infobox + std::string str = item->hintText.empty() ? g_Locale->getText(item->hint) : item->hintText; + if (info_box == NULL) + info_box = new CComponentsInfoBox(); + + info_box->setDimensionsAll(x, ypos2, iwidth, hint_height); + info_box->setFrameThickness(g_settings.show_menu_hints_line ? 1 : 0); //NI + //NI info_box->removeLineBreaks(str); + info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT); + info_box->setCorner(RADIUS_LARGE); + info_box->setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENTDARK_PLUS_0); + info_box->setTextColor(COL_MENUCONTENTDARK_TEXT); + info_box->enableShadow(); + info_box->setPicture(item->hintIcon ? item->hintIcon : ""); + info_box->enableColBodyGradient(g_settings.theme.menu_Hint_gradient, COL_MENUFOOT_PLUS_0, g_settings.theme.menu_Hint_gradient_direction);// COL_MENUFOOT_PLUS_0 is default footer color + + //paint result + if (details_line) + details_line->paint(); + if (info_box) + info_box->paint(savescreen); + + hint_painted = info_box ? info_box->isPainted() : false; +} + +void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string & action) +{ + keyActionMap[key].menue = menue; + keyActionMap[key].action = action; +} + +void CMenuWidget::setFooter(const struct button_label *_fbutton_labels, const int _fbutton_count, bool repaint) +{ + fbutton_count = _fbutton_count; + fbutton_labels = _fbutton_labels; + + fbutton_width = 0; + fbutton_height = 0; + if (fbutton_count) + paintButtons(fbutton_labels, fbutton_count, 0, 0, 0, 0, 0, false, &fbutton_width, &fbutton_height); + if (repaint) + paint(); +} + + +//------------------------------------------------------------------------------------------------------------------------------- +CMenuOptionNumberChooser::CMenuOptionNumberChooser( const neutrino_locale_t Name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, + CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, + const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init(Name, "", OptionValue, min_value, max_value, print_offset, special_value, special_value_name, Observ, sliderOn); +} + +CMenuOptionNumberChooser::CMenuOptionNumberChooser( const std::string &Name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, + CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, + const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init(NONEXISTANT_LOCALE, Name, OptionValue, min_value, max_value, print_offset, special_value, special_value_name, Observ, sliderOn); +} + +void CMenuOptionNumberChooser::init( const neutrino_locale_t& lName, + const std::string &sName, + int* const Option_Value, + const int& min_value, + const int& max_value, + const int& print_offset, + const int& special_value, + const neutrino_locale_t& special_value_name, + CChangeObserver * const Observ, + bool sliderOn) +{ + name = lName; + nameString = sName; + optionValue = Option_Value; + lower_bound = min_value; + upper_bound = max_value; + display_offset = print_offset; + localized_value = special_value; + localized_value_name = special_value_name; + observ = Observ; + slider_on = sliderOn; + + numberFormat = "%d"; + numberFormatFunction = NULL; + directKeyOK = false; + numeric_input = false; +} + +int CMenuOptionNumberChooser::exec(CMenuTarget*) +{ + int res = menu_return::RETURN_NONE; + + if(msg == CRCInput::RC_left) { + if (((*optionValue) > upper_bound) || ((*optionValue) <= lower_bound)) + *optionValue = upper_bound; + else + (*optionValue)--; + } else if (numeric_input && msg == CRCInput::RC_ok) { + int size = 0; + int b = lower_bound; + if (b < 0) { + size++, + b = -b; + } + if (b < upper_bound) + b = upper_bound; + for (; b; b /= 10, size++); + CIntInput cii(name, optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + cii.exec(NULL, ""); + if (*optionValue > upper_bound) + *optionValue = upper_bound; + else if (*optionValue < lower_bound) + *optionValue = lower_bound; + res = menu_return::RETURN_REPAINT; + } else { + if (((*optionValue) >= upper_bound) || ((*optionValue) < lower_bound)) + *optionValue = lower_bound; + else + (*optionValue)++; + } + + bool wantsRepaint = false; + if(observ && !luaAction.empty()) { + // optionValue is int* + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str()); + } else if(observ) + wantsRepaint = observ->changeNotify(name, optionValue); + + // give the observer a chance to modify the value + paint(true); + OnAfterChangeOption(); + if (wantsRepaint) + res = menu_return::RETURN_REPAINT; + + return res; +} + +int CMenuOptionNumberChooser::paint(bool selected) +{ + const char * l_option; + char option_value[40]; + + if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value)) + { + if (numberFormatFunction) { + std::string s = numberFormatFunction(*optionValue + display_offset); + strncpy(option_value, s.c_str(), sizeof(option_value)); + } else + sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset); + l_option = option_value; + } + else + l_option = g_Locale->getText(localized_value_name); + + //paint item + prepareItem(selected, height); + + //paint item icon + paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); + if(slider_on) + paintItemSlider(selected, height, *optionValue, (upper_bound - lower_bound), getName(), l_option); + //paint text + paintItemCaption(selected, l_option); + + return y+height; +} + +int CMenuOptionNumberChooser::getWidth(void) +{ + int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); + int _lower_bound = lower_bound; + int _upper_bound = upper_bound; + int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth(); + + int w1 = 0; + if (_lower_bound < 0) + w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-"); + while (_lower_bound) { + w1 += m; + _lower_bound /= 10; + } + + int w2 = 0; + if (_upper_bound < 0) + w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-"); + while (_upper_bound) { + w1 += m; + _upper_bound /= 10; + } + + width += (w1 > w2) ? w1 : w2; + + if (numberFormatFunction) { + std::string s = numberFormatFunction(0); + width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); // arbitrary + } else if (numberFormat != "%d") { + char format[numberFormat.length()]; + snprintf(format, numberFormat.length(), numberFormat.c_str(), 0); + width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); + } + + width += OFFSET_INNER_MID; /* min 10 pixels between option name and value. enough? */ + + const char *desc_text = getDescription(); + if (*desc_text) + width = std::max(width, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + return width; +} + +CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init("", OptionName, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); +} + +CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init(OptionName, NONEXISTANT_LOCALE, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); +} + +CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init("", OptionName, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); +} + +CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); +} + +CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init("", OptionName, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort); +} + +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector &Options, + const bool Active, CChangeObserver * const Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) + : CAbstractMenuOptionChooser(Active, DirectKey, IconName) +{ + init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort); +} + +CMenuOptionChooser::~CMenuOptionChooser() +{ + clearChooserOptions(); +} + +void CMenuOptionChooser::init( const std::string &OptionName, + const neutrino_locale_t Name, + int * const OptionValue, + const struct keyval * const Options, + const struct keyval_ext * const OptionsExt, + std::vector * v_Options, + const size_t Number_Of_Options, + CChangeObserver * const Observ, + bool Pulldown, + bool OptionsSort) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = OptionName; + name = Name; + optionValue = OptionValue; + number_of_options = Number_Of_Options; + observ = Observ; + pulldown = Pulldown; + optionsSort = OptionsSort; + + if (Options || OptionsExt) + { + if (Options) + { + for (unsigned int i = 0; i < number_of_options; i++) + { + struct keyval_ext opt; + opt = Options[i]; + options.push_back(opt); + } + } + + if (OptionsExt) + { + for (unsigned int i = 0; i < number_of_options; i++) + options.push_back(OptionsExt[i]); + } + } + else{ + if (v_Options) + options = *v_Options; + } +} + +void CMenuOptionChooser::clearChooserOptions() +{ + for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) + delete *it; + + option_chooser_options_v.clear(); +} + +void CMenuOptionChooser::setOptions(const struct keyval * const Options, const unsigned Number_Of_Options) +{ + options.clear(); + number_of_options = Number_Of_Options; + for (unsigned int i = 0; i < number_of_options; i++) + { + struct keyval_ext opt; + opt = Options[i]; + options.push_back(opt); + } + if (used && x != -1) + paint(false); +} + +void CMenuOptionChooser::setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options) +{ + options.clear(); + number_of_options = Number_Of_Options; + for (unsigned int i = 0; i < number_of_options; i++) + options.push_back(Options[i]); + if (used && x != -1) + paint(false); +} + +void CMenuOptionChooser::setOption(const int newvalue) +{ + *optionValue = newvalue; +} + +int CMenuOptionChooser::getOption(void) const +{ + return *optionValue; +} + + +int CMenuOptionChooser::exec(CMenuTarget*) +{ + bool wantsRepaint = false; + int ret = menu_return::RETURN_NONE; + char *optionValname = NULL; + + if (optionsSort) { + optionsSort = false; + clearChooserOptions(); + unsigned int i1; + for (i1 = 0; i1 < number_of_options; i1++) + { + CMenuOptionChooserOptions* co = new CMenuOptionChooserOptions(); + co->key = options[i1].key; + co->valname = (options[i1].valname != 0) ? options[i1].valname : g_Locale->getText(options[i1].value); + option_chooser_options_v.push_back(co); + } + + sort(option_chooser_options_v.begin(), option_chooser_options_v.end(), CMenuOptionChooserCompareItem()); + + options.clear(); + for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) { + struct keyval_ext opt; + opt.key = (*it)->key; + opt.value = NONEXISTANT_LOCALE; + opt.valname = (*it)->valname.c_str(); + options.push_back(opt); + } + } + + if((msg == CRCInput::RC_ok) && pulldown) { + int select = -1; + CMenuWidget* menu = new CMenuWidget(getName(), NEUTRINO_ICON_SETTINGS); + menu->enableFade(false); + /* FIXME: BACK button with hints enabled - parent menu getting holes, possible solution + * to hide parent, or add hints ? */ + menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); + // menu->move(20, 0); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); + for(unsigned int count = 0; count < number_of_options; count++) + { + bool selected = false; + const char * l_option; + if (options[count].key == (*optionValue)) + selected = true; + + if(options[count].valname != 0) + l_option = options[count].valname; + else + l_option = g_Locale->getText(options[count].value); + CMenuForwarder *mn_option = new CMenuForwarder(l_option, true, NULL, selector, to_string(count).c_str()); + mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); + menu->addItem(mn_option, selected); + } + menu->exec(NULL, ""); + ret = menu_return::RETURN_REPAINT;; + if(select >= 0) + { + *optionValue = options[select].key; + optionValname = (char *) options[select].valname; + } + delete menu; + delete selector; + } else { + for(unsigned int count = 0; count < number_of_options; count++) { + if (options[count].key == (*optionValue)) { + if(msg == CRCInput::RC_left) { + if(count > 0) + optionValname = (char *) options[(count-1) % number_of_options].valname, + *optionValue = options[(count-1) % number_of_options].key; + else + optionValname = (char *) options[number_of_options-1].valname, + *optionValue = options[number_of_options-1].key; + } else + optionValname = (char *) options[(count+1) % number_of_options].valname, + *optionValue = options[(count+1) % number_of_options].key; + break; + } + } + } + paint(true); + OnAfterChangeOption(); + if(observ && !luaAction.empty()) { + if (optionValname) + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname); + } else if(observ) + wantsRepaint = observ->changeNotify(name, optionValue); + + if (wantsRepaint) + ret = menu_return::RETURN_REPAINT; + + return ret; +} + +int CMenuOptionChooser::paint( bool selected) +{ + neutrino_locale_t option = NONEXISTANT_LOCALE; + const char * l_option = NULL; + + for(unsigned int count = 0 ; count < number_of_options; count++) { + if (options[count].key == *optionValue) { + option = options[count].value; + if(options[count].valname != 0) + l_option = options[count].valname; + else + l_option = g_Locale->getText(option); + break; + } + } + + if(l_option == NULL) + { + *optionValue = options[0].key; + option = options[0].value; + if(options[0].valname != 0) + l_option = options[0].valname; + else + l_option = g_Locale->getText(option); + } + + //paint item + prepareItem(selected, height); + + //paint item icon + paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); + + //paint text + paintItemCaption(selected, l_option); + + return y+height; +} + +int CMenuOptionChooser::getWidth(void) +{ + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); + int width = tw; + + for(unsigned int count = 0; count < options.size(); count++) { + int ow = 0; + if (options[count].valname) + ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(options[count].valname); + else + ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(options[count].value)); + + if (tw + ow > width) + width = tw + ow; + } + + width += OFFSET_INNER_MID; /* min 10 pixels between option name and value. enough? */ + const char *desc_text = getDescription(); + if (*desc_text) + width = std::max(width, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + return width; +} + +//------------------------------------------------------------------------------------------------------------------------------- + +CMenuOptionStringChooser::CMenuOptionStringChooser( const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) + : CMenuItem(Active, DirectKey, IconName) +{ + init("", OptionName, OptionValue, Observ, Pulldown); +} + +CMenuOptionStringChooser::CMenuOptionStringChooser( const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, + const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) + : CMenuItem(Active, DirectKey, IconName) +{ + init(OptionName, NONEXISTANT_LOCALE, OptionValue, Observ, Pulldown); +} + +void CMenuOptionStringChooser::init( const std::string &OptionName, + const neutrino_locale_t Name, + std::string* pOptionValue, + CChangeObserver * const Observ, + bool Pulldown) +{ + nameString = OptionName; + name = Name; + optionValuePtr = pOptionValue ? pOptionValue : &optionValue; + observ = Observ; + pulldown = Pulldown; +} + + +CMenuOptionStringChooser::~CMenuOptionStringChooser() +{ + options.clear(); +} + +void CMenuOptionStringChooser::setTitle(std::string &Title) +{ + title = Title; +} + +void CMenuOptionStringChooser::setTitle(const neutrino_locale_t Title) +{ + title = g_Locale->getText(Title); +} + +void CMenuOptionStringChooser::addOption(const std::string &value) +{ + options.push_back(value); +} + +void CMenuOptionStringChooser::sortOptions() +{ + sort(options.begin(), options.end()); +} + +int CMenuOptionStringChooser::exec(CMenuTarget* parent) +{ + bool wantsRepaint = false; + int ret = menu_return::RETURN_NONE; + + if((!parent || msg == CRCInput::RC_ok) && pulldown) { + int select = -1; + + if (parent) + parent->hide(); + + std::string title_str = title.empty() ? getName() : title; + + CMenuWidget* menu = new CMenuWidget(title_str, NEUTRINO_ICON_SETTINGS); + menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); + //if(parent) menu->move(20, 0); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); + for(unsigned int count = 0; count < options.size(); count++) + { + bool selected = optionValuePtr && (options[count] == *optionValuePtr); + CMenuForwarder *mn_option = new CMenuForwarder(options[count], true, NULL, selector, to_string(count).c_str()); + mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); + menu->addItem(mn_option, selected); + } + menu->exec(NULL, ""); + ret = menu_return::RETURN_REPAINT; + if(select >= 0 && optionValuePtr) + *optionValuePtr = options[select]; + delete menu; + delete selector; + } else { + //select next value + for(unsigned int count = 0; count < options.size(); count++) { + if (optionValuePtr && (options[count] == *optionValuePtr)) { + if(msg == CRCInput::RC_left) { + if(count > 0) + *optionValuePtr = options[(count - 1) % options.size()]; + else + *optionValuePtr = options[options.size() - 1]; + } else + *optionValuePtr = options[(count + 1) % options.size()]; + //wantsRepaint = true; + break; + } + } + + paint(true); + } + if(observ && !luaAction.empty()) + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValuePtr ? optionValuePtr->c_str() : "")); + else if(observ) { + wantsRepaint = observ->changeNotify(name, (void *)(optionValuePtr ? optionValuePtr->c_str() : "")); + } + if (wantsRepaint) + ret = menu_return::RETURN_REPAINT; + + return ret; +} + +int CMenuOptionStringChooser::paint( bool selected ) +{ + //paint item + prepareItem(selected, height); + + //paint item icon + paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); + + //paint text + paintItemCaption(selected, optionValuePtr->c_str()); + + return y+height; +} + +//------------------------------------------------------------------------------------------------------------------------------- +CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init("", Text, Option, NULL, Target, ActionKey); +} + +CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init(Text, NONEXISTANT_LOCALE, Option, NULL, Target, ActionKey); +} + +CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init("", Text, "", Option, Target, ActionKey); +} + +CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, + neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) + : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) +{ + init(Text, NONEXISTANT_LOCALE, "", Option, Target, ActionKey); +} + +void CMenuForwarder::init( const std::string &Text, + const neutrino_locale_t Name, + const std::string &sOption, + const char * const cOption, + CMenuTarget* Target, + const char * const ActionKey) +{ + nameString = Text; + name = Name; + + if (sOption.empty()) + { + option_string = cOption ? cOption : ""; + option_string_ptr = &option_string; + } + else + option_string_ptr = &sOption; + + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; +} + +void CMenuForwarder::setOption(const std::string &Option) +{ + option_string = Option; + option_string_ptr = &option_string; +} + +int CMenuForwarder::getWidth(void) +{ + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); + + fb_pixel_t bgcol = 0; + std::string option_name = getOption(); + if (jumpTarget) + bgcol = jumpTarget->getColor(); + + if (!option_name.empty()) + tw += OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name); + else if (bgcol) + tw += OFFSET_INNER_MID + CFrameBuffer::getInstance()->scale2Res(60); + + const char *desc_text = getDescription(); + if (*desc_text) + tw = std::max(tw, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); + return tw; +} + +int CMenuForwarder::exec(CMenuTarget* parent) +{ + if(jumpTarget) + return jumpTarget->exec(parent, actionKey); + return menu_return::RETURN_EXIT; +} + +std::string CMenuForwarder::getOption(void) +{ + if (!option_string_ptr->empty()) + return *option_string_ptr; + if (jumpTarget) + return jumpTarget->getValue(); + return ""; +} + +int CMenuForwarder::paint(bool selected) +{ + std::string option_name = getOption(); + + fb_pixel_t bgcol = 0; + if (jumpTarget) + bgcol = jumpTarget->getColor(); + + //paint item + prepareItem(selected, height); + + //paint icon + paintItemButton(selected, height); + + //caption + paintItemCaption(selected, option_name.c_str(), bgcol); + + return y+ height; +} + +//------------------------------------------------------------------------------------------------------------------------------- +CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) +{ + init(Type, Text, ""); +} + +CMenuSeparator::CMenuSeparator(const int Type, const std::string &Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) +{ + init(Type, NONEXISTANT_LOCALE, Text); +} + +void CMenuSeparator::init(const int& Type, const neutrino_locale_t& lText, const std::string &sText) +{ + type = Type; + name = lText; + nameString = sText; +} + +int CMenuSeparator::getHeight(void) +{ + if (nameString.empty() && name == NONEXISTANT_LOCALE) + return OFFSET_INNER_MID; + return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); +} + +int CMenuSeparator::getWidth(void) +{ + int w = 0; + if (type & LINE) + w = 2*OFFSET_INNER_MID; /* offset left and right */ + const char *l_name = getName(); + if ((type & STRING) && *l_name) + w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); + return w; +} + +int CMenuSeparator::paint(bool selected) +{ + height = getHeight(); + CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); + + if ((type & SUB_HEAD)) + { + item_color = COL_MENUHEAD_TEXT; + item_bgcolor = g_settings.theme.menu_Head_gradient ? COL_MENUCONTENT_PLUS_0 : COL_MENUHEAD_PLUS_0; + } + else + { + item_color = COL_MENUCONTENTINACTIVE_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_0; + } + + frameBuffer->paintBoxRel(x,y, dx, height, item_bgcolor); + if ((type & LINE)) + { + int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF; + paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); + } + if ((type & STRING)) + { + const char * l_name = getName(); + + if (*l_name) + { + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); + int iconwidth, iconheight; + CFrameBuffer::getInstance()->getIconSize(NEUTRINO_ICON_BUTTON_HOME, &iconwidth, &iconheight); + + /* if no alignment is specified, align centered */ + if (type & ALIGN_LEFT) + name_start_x = x + (!(type & SUB_HEAD) ? name_start_x : 2*OFFSET_INNER_MID + iconwidth); + else if (type & ALIGN_RIGHT) + name_start_x = x + dx - stringwidth - 2*OFFSET_INNER_MID; + else /* ALIGN_CENTER */ + name_start_x = x + (dx >> 1) - (stringwidth >> 1); + + frameBuffer->paintBoxRel(name_start_x-OFFSET_INNER_SMALL, y, stringwidth+2*OFFSET_INNER_SMALL, height, item_bgcolor); + + if ((type & LINE)) //NI - use COL_MENUHEAD_TEXT for CMenuSeparators defined with LINE and STRING + item_color = COL_MENUHEAD_TEXT; + + paintItemCaption(selected); + } + } + return y+ height; +} + +bool CPINProtection::check() +{ + hint = NONEXISTANT_LOCALE; + std::string cPIN; + do + { + cPIN = ""; + CPINInput* PINInput = new CPINInput(title, &cPIN, 4, hint); + PINInput->exec( getParent(), ""); + delete PINInput; + hint = LOCALE_PINPROTECTION_WRONGCODE; + } while ((cPIN != *validPIN) && !cPIN.empty()); + return (cPIN == *validPIN); +} + + +bool CZapProtection::check() +{ + hint = NONEXISTANT_LOCALE; + int res; + std::string cPIN; + do + { + cPIN = ""; + + CPLPINInput* PINInput = new CPLPINInput(title, &cPIN, 4, hint, fsk); + + res = PINInput->exec(getParent(), ""); + delete PINInput; + if (!access(CONFIGDIR "/pinentered.sh", X_OK)) { + std::string systemstr = CONFIGDIR "/pinentered.sh " + cPIN; + system(systemstr.c_str()); + } + hint = LOCALE_PINPROTECTION_WRONGCODE; + } while ( (cPIN != *validPIN) && !cPIN.empty() && + ( res == menu_return::RETURN_REPAINT ) && + ( fsk >= g_settings.parentallock_lockage ) ); + return ( (cPIN == *validPIN) || + ( fsk < g_settings.parentallock_lockage ) ); +} + +int CLockedMenuForwarder::exec(CMenuTarget* parent) +{ + Parent = parent; + + if (Ask && !check()) + { + Parent = NULL; + return menu_return::RETURN_REPAINT; + } + + Parent = NULL; + return CMenuForwarder::exec(parent); +} + +int CMenuSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & actionKey) +{ + if (!actionKey.empty()) + *m_select = atoi(actionKey); + else + *m_select = -1; + return menu_return::RETURN_EXIT; +} + +CMenuProgressbar::CMenuProgressbar(const neutrino_locale_t Text) : CMenuItem(true, CRCInput::RC_nokey, NULL, NULL, false) +{ + init(Text, ""); +} + +CMenuProgressbar::CMenuProgressbar(const std::string &Text) : CMenuItem(true, CRCInput::RC_nokey, NULL, NULL, false) +{ + init(NONEXISTANT_LOCALE, Text); +} + +void CMenuProgressbar::init(const neutrino_locale_t Loc, const std::string &Text) +{ + name = Loc; + nameString = Text; + scale.setDimensionsAll(0, 0, 100, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()/2); + scale.setValues(100, 100); +} + +int CMenuProgressbar::paint(bool selected) +{ + //paint item + prepareItem(selected, height); + + //left text + const char *left_text = getName(); + int _dx = dx; + + if (*left_text) + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y + height, _dx- (name_start_x - x), left_text, item_color); + + //progress bar + int pb_x; + if (*left_text) + pb_x = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - scale.getWidth() - icon_frame_w); + else + pb_x = name_start_x; + + scale.setPos(pb_x, y + (height - scale.getHeight())/2); + scale.reset(); + scale.paint(); + + return y + height; +} + +int CMenuProgressbar::getHeight(void) +{ + return std::max(CMenuItem::getHeight(), scale.getHeight()); +} + +int CMenuProgressbar::getWidth(void) +{ + int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); + if (width) + width += OFFSET_INNER_MID; + return width + scale.getWidth(); +} + +int CMenuProgressbar::exec(CMenuTarget*) +{ + int val = scale.getValue() + 25; + if (val > 100) + val = 0; + scale.setValue(val); + scale.reset(); + scale.paint(); + return menu_return::RETURN_NONE; +} diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 6c89f878e..ce736ada3 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -553,7 +553,7 @@ class CMenuWidget : public CMenuTarget, public CComponentsSignals int preselected; int selected; int iconOffset; - int sb_width; + int scrollbar_width; fb_pixel_t *background; int full_width, full_height; bool savescreen; From 9e311becdf3afe5780a4febd9934c15b894f4cc5 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 7 Sep 2017 16:18:30 +0200 Subject: [PATCH 37/40] keybind_setup: resort items as in other menus too; 'save' before 'load' Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c11a78a28ac5ebcb1f11ec73891a1e5475a12f4c Author: vanhofen Date: 2017-09-07 (Thu, 07 Sep 2017) Origin message was: ------------------ - keybind_setup: resort items as in other menus too; 'save' before 'load' ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/keybind_setup.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 0926595c4..d8fa7735b 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -245,7 +245,7 @@ int CKeybindSetup::showKeySetup() //keysetup menu CMenuWidget* keySettings = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_KEYBINDING, width, MN_WIDGET_ID_KEYSETUP); - keySettings->addIntroItems(LOCALE_MAINSETTINGS_KEYBINDING, LOCALE_KEYBINDINGMENU_HEAD); + keySettings->addIntroItems(LOCALE_MAINSETTINGS_KEYBINDING); //keybindings menu CMenuWidget bindSettings(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_KEYBINDING, width, MN_WIDGET_ID_KEYSETUP_KEYBINDING); @@ -261,12 +261,12 @@ int CKeybindSetup::showKeySetup() mf->setHint("", LOCALE_MENU_HINT_KEY_BINDING); keySettings->addItem(mf); - mf = new CMenuForwarder(LOCALE_EXTRA_LOADKEYS, true, NULL, this, "loadkeys", CRCInput::RC_green); - mf->setHint("", LOCALE_MENU_HINT_KEY_LOAD); + mf = new CMenuForwarder(LOCALE_EXTRA_SAVEKEYS, true, NULL, this, "savekeys", CRCInput::RC_green); + mf->setHint("", LOCALE_MENU_HINT_KEY_SAVE); keySettings->addItem(mf); - mf = new CMenuForwarder(LOCALE_EXTRA_SAVEKEYS, true, NULL, this, "savekeys", CRCInput::RC_yellow); - mf->setHint("", LOCALE_MENU_HINT_KEY_SAVE); + mf = new CMenuForwarder(LOCALE_EXTRA_LOADKEYS, true, NULL, this, "loadkeys", CRCInput::RC_yellow); + mf->setHint("", LOCALE_MENU_HINT_KEY_LOAD); keySettings->addItem(mf); keySettings->addItem(GenericMenuSeparatorLine); From 747566f187707ec2860b136db1a3aa65e4a1087b Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 7 Sep 2017 16:18:30 +0200 Subject: [PATCH 38/40] locale: small changes; unify save/load locales Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/c76b874c7075f6835e5dd6d7df805485cd90fc6f Author: vanhofen Date: 2017-09-07 (Thu, 07 Sep 2017) Origin message was: ------------------ - locale: small changes; unify save/load locales ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/locale/deutsch.locale | 24 ++++++++++++------------ data/locale/english.locale | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 46c1a0e73..9fe918891 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -227,11 +227,11 @@ bouqueteditor.savingchanges Änderungen werden gespeichert. Bitte warten ... bouqueteditor.switch Kanal aufnehmen/entfernen bouqueteditor.switchmode TV/Radio bouquetlist.head Bouquets -bouquetname.hdtv HD Kanäle +bouquetname.hdtv HD-Kanäle bouquetname.new Neue Kanäle bouquetname.other Unbekannter Provider bouquetname.removed Gelöschte Kanäle -bouquetname.webtv WebTV Kanäle +bouquetname.webtv WebTV-Kanäle buildinfo.compiled_on Build Host buildinfo.compiled_with Compiler Version buildinfo.compiler_flags Compiler Flags @@ -504,8 +504,8 @@ extra.key_timeshift Timeshift extra.key_unlock Entsperrtaste extra.ladirection Breitengrad-Ausrichtung extra.latitude Breitengrad -extra.loadconfig Einstellungen: Laden von -extra.loadkeys Lade Tastenbelegung von +extra.loadconfig Einstellungen laden +extra.loadkeys Tastenbelegungen laden extra.lodirection Längengrad-Ausrichtung extra.longitude Längengrad extra.menu_left_exit "links" = Menü zurück @@ -516,8 +516,8 @@ extra.rotor_swap Rotor dreht Ost/West extra.rounded_corners Eckendarstellung extra.rounded_corners_off eckig extra.rounded_corners_on abgerundet -extra.saveconfig Einstellungen: Sichern als -extra.savekeys Speichere Tastenbelegung als +extra.saveconfig Einstellungen sichern +extra.savekeys Tastenbelegungen sichern extra.scrambled_message Verschlüsselung melden extra.show_mute_icon Mute-Icon bei Lautstärke 0 extra.sms_channel SMS-Modus bei Kanalsuche @@ -945,8 +945,8 @@ keybindingmenu.cancel Kanalliste schließen keybindingmenu.channeldown Kanal runter keybindingmenu.channellist Kanalliste keybindingmenu.channelup Kanal hoch -keybindingmenu.edit Bearbeiten -keybindingmenu.head Tasten-Belegungen bearbeiten +keybindingmenu.edit Tastenbelegungen bearbeiten +keybindingmenu.head Tastenbelegungen keybindingmenu.lastchannel Letzter Kanal keybindingmenu.longkeypress_duration Langer Tastendruck keybindingmenu.misc Sonstige @@ -1313,7 +1313,7 @@ menu.hint_key_record Konfigurieren Sie die Taste für den Aufnahmestart menu.hint_key_repeatblock Die Verzögerung nach einem Tastendruck bis die Box reagieren soll menu.hint_key_repeatblockgeneric Die Verzögerung zwischen den Tastewiederholungen bis die Box reagieren soll menu.hint_key_right Wählen Sie die Funktion für die Tasten 'links' und 'rechts' im TV/Radio- und Movieplayer-Modus -menu.hint_key_save Speichern Sie Ihre Tastenbelegungen in einer Datei ab +menu.hint_key_save Speichern Sie Ihre Tastenbelegungen in einer Datei namens keys.conf ab menu.hint_key_screenshot Weisen Sie eine Taste zu, um Menü- und/oder TV-Screenshots zu speichern menu.hint_key_sort Weisen Sie eine Taste für das Sortieren in der Kanalliste zu menu.hint_key_special_active Deaktivieren oder aktivieren einiger Sondertasten @@ -1504,7 +1504,7 @@ menu.hint_restore Wiederherstellen von vorher erstellten Sicherungen menu.hint_rotor_swap Tauschen der Rotordrehrichtung Ost/West in den Motor-Einstellungen menu.hint_rounded_corners Aktiviert die Darstellung abgerundeter Ecken für die Menüs menu.hint_save_settings Speichert ihre Einstellungen -menu.hint_saveas Speichern der Einstellungen in eine Datei +menu.hint_saveas Speichern der Einstellungen in einer Datei namens neutrino.conf menu.hint_scan_auto Automatischer Suchlauf ausgewählter Anbieter menu.hint_scan_autoall Automatischer Suchlauf aller ausgewählten Anbieter menu.hint_scan_autoall_select Suchlauf nur in ausgewählten Satelliten @@ -2533,7 +2533,7 @@ servicemenu.restart_tuner Tuner neu starten servicemenu.restarting_tuner Tuner wird neu gestartet servicemenu.scants Kanalsuche servicemenu.update Software-Aktualisierung -settings.backup NI-Backup: Sichern +settings.backup NI-Backup sichern settings.backup_failed Sicherung fehlgeschlagen! settings.help Hilfe settings.menu_hints Hinweise anzeigen @@ -2550,7 +2550,7 @@ settings.pos_higher_center höher zentriert settings.pos_top_center oben zentriert settings.pos_top_left oben links settings.pos_top_right oben rechts -settings.restore NI-Backup: Wiederherstellen +settings.restore NI-Backup wiederherstellen settings.restore_warn Alle Settings werden ersetzt.\nDie Box wird neu gestartet.\nWeiter? settings.teams Team-übergreifende Einstellungen settings.teams.backup Sichern diff --git a/data/locale/english.locale b/data/locale/english.locale index ff05ac989..44ba3dcfd 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -504,8 +504,8 @@ extra.key_timeshift Timeshift extra.key_unlock Unlock key extra.ladirection LaDirection extra.latitude Latitude -extra.loadconfig Settings: Load from -extra.loadkeys Load keys from +extra.loadconfig Load settings +extra.loadkeys Load keybindings extra.lodirection LoDirection extra.longitude Longitude extra.menu_left_exit "Left" = menu back @@ -516,8 +516,8 @@ extra.rotor_swap Swap rotor east/west extra.rounded_corners Shape of corners extra.rounded_corners_off angular extra.rounded_corners_on rounded -extra.saveconfig Settings: Save as -extra.savekeys Save keys as +extra.saveconfig Save settings +extra.savekeys Save keybindings extra.scrambled_message Scrambled Message extra.show_mute_icon mute-icon at volume 0 extra.sms_channel SMS-mode channel @@ -945,8 +945,8 @@ keybindingmenu.cancel close channellist keybindingmenu.channeldown channel down keybindingmenu.channellist Channellist keybindingmenu.channelup channel up -keybindingmenu.edit Edit -keybindingmenu.head Edit Keybindings +keybindingmenu.edit Edit keybindings +keybindingmenu.head Keybindings keybindingmenu.lastchannel Quick Zap keybindingmenu.longkeypress_duration Long key-press keybindingmenu.misc Misc @@ -1313,7 +1313,7 @@ menu.hint_key_record Assign button to start a recording menu.hint_key_repeatblock Delay after button press and before\nfirst key repeat menu.hint_key_repeatblockgeneric Delay between key repeats\nwhile button pressed menu.hint_key_right Select function for 'left' and 'right' keys in live TV/Radio mode and movieplayer mode -menu.hint_key_save Save keybindings to file +menu.hint_key_save Save keybindings to a file named keys.conf menu.hint_key_screenshot Assign button to save GUI and/or TV screenshot menu.hint_key_sort Assign button to change channel list sort order menu.hint_key_special_active Disable or enable some special keys @@ -1504,7 +1504,7 @@ menu.hint_restore Restore files from selected backup menu.hint_rotor_swap Swap rotor east/west directions\nin motor control menu.hint_rounded_corners Draw round or rectangular windows corners menu.hint_save_settings Save all settings to flash -menu.hint_saveas Save GUI settings to file +menu.hint_saveas Save GUI settings to a file named neutrino.conf menu.hint_scan_auto Auto-scan selected provider menu.hint_scan_autoall Scan several selected providers at once menu.hint_scan_autoall_select Add selected satellites to scan @@ -2533,7 +2533,7 @@ servicemenu.restart_tuner Restart tuner servicemenu.restarting_tuner Restarting tuner servicemenu.scants Servicescan servicemenu.update Software Update -settings.backup NI-Backup: save +settings.backup Save NI-Backup settings.backup_failed Backup failed! settings.help Help settings.menu_hints Show menu hints @@ -2550,7 +2550,7 @@ settings.pos_higher_center higher center settings.pos_top_center top center settings.pos_top_left top left settings.pos_top_right top right -settings.restore NI-Backup: restore +settings.restore Load NI-Backup settings.restore_warn This will replace all settings and reboot\nContinue ? settings.teams Cross-Team Settings settings.teams.backup Save From 4523dc5e0abad08816ae3af586f1968c2746155a Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 7 Sep 2017 16:18:30 +0200 Subject: [PATCH 39/40] don't save conf-files to flash; use /media by default Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/909201ae662cb306a60c169687eb4d3e9104a628 Author: vanhofen Date: 2017-09-07 (Thu, 07 Sep 2017) Origin message was: ------------------ - don't save conf-files to flash; use /media by default ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/keybind_setup.cpp | 2 +- src/gui/settings_manager.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index d8fa7735b..b6388d6aa 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -106,7 +106,7 @@ int CKeybindSetup::exec(CMenuTarget* parent, const std::string &actionKey) else if(actionKey == "savekeys") { CFileBrowser fileBrowser; fileBrowser.Dir_Mode = true; - if (fileBrowser.exec("/var/tuxbox") == true) { + if (fileBrowser.exec("/media") == true) { std::string fname = "keys.conf"; CKeyboardInput * sms = new CKeyboardInput(LOCALE_EXTRA_SAVEKEYS, &fname); sms->exec(NULL, ""); diff --git a/src/gui/settings_manager.cpp b/src/gui/settings_manager.cpp index afda60eaf..612ecd7bd 100644 --- a/src/gui/settings_manager.cpp +++ b/src/gui/settings_manager.cpp @@ -91,7 +91,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) else if(actionKey == "saveconfig") { fileBrowser.Dir_Mode = true; - if (fileBrowser.exec("/var/tuxbox") == true) + if (fileBrowser.exec("/media") == true) { std::string fname = "neutrino.conf"; CKeyboardInput * sms = new CKeyboardInput(LOCALE_EXTRA_SAVECONFIG, &fname); From 7c1d2e38fe8674b746711aa138bc663d1b4dbbfb Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 7 Sep 2017 16:20:43 +0200 Subject: [PATCH 40/40] delete edit/patch crap Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/9be1fa1c8ac561d0c6574373813efa43b093f03c Author: vanhofen Date: 2017-09-07 (Thu, 07 Sep 2017) Origin message was: ------------------ - delete edit/patch crap ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/gui/widget/menue.cpp.orig | 2480 --------------------------------- 1 file changed, 2480 deletions(-) delete mode 100644 src/gui/widget/menue.cpp.orig diff --git a/src/gui/widget/menue.cpp.orig b/src/gui/widget/menue.cpp.orig deleted file mode 100644 index 90cfeb631..000000000 --- a/src/gui/widget/menue.cpp.orig +++ /dev/null @@ -1,2480 +0,0 @@ -/* - Neutrino-GUI - DBoxII-Project - - Copyright (C) 2001 Steffen Hehn 'McClean' - Homepage: http://dbox.cyberphoria.org/ - - (C) 2008, 2009 Stefan Seyfried - Copyright (C) 2012 CoolStream International Ltd - - License: GPLv2 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - - -#include -#include -#include - -#include -#include -#include -#include -#include - - -#include -#include -#include - -#include - -//NI lcd4l-support -#include "gui/lcd4l.h" -extern CLCD4l *LCD4l; - -/* the following generic menu items are integrated into multiple menus at the same time */ -CMenuSeparator CGenericMenuSeparator(0, NONEXISTANT_LOCALE, true); -CMenuSeparator CGenericMenuSeparatorLine(CMenuSeparator::LINE, NONEXISTANT_LOCALE, true); -CMenuForwarder CGenericMenuBack(LOCALE_MENU_BACK, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_LEFT, NULL, true); -CMenuForwarder CGenericMenuCancel(LOCALE_MENU_CANCEL, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_HOME, NULL, true); -CMenuForwarder CGenericMenuNext(LOCALE_MENU_NEXT, true, NULL, NULL, NULL, CRCInput::RC_nokey, NEUTRINO_ICON_BUTTON_RIGHT, NULL, true); -CMenuSeparator * const GenericMenuSeparator = &CGenericMenuSeparator; -CMenuSeparator * const GenericMenuSeparatorLine = &CGenericMenuSeparatorLine; -CMenuForwarder * const GenericMenuBack = &CGenericMenuBack; -CMenuForwarder * const GenericMenuCancel = &CGenericMenuCancel; -CMenuForwarder * const GenericMenuNext = &CGenericMenuNext; - -CMenuItem::CMenuItem(bool Active, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) -{ - active = current_active = Active; - directKey = DirectKey; - isStatic = IsStatic; - - if (IconName && *IconName) - iconName = IconName; - else - setIconName(); - - if (IconName_Info_right && *IconName_Info_right) - iconName_Info_right = IconName_Info_right; - else - iconName_Info_right = NULL; - - hintIcon = NULL; - - x = -1; - used = false; - icon_frame_w = OFFSET_INNER_MID; - hint = NONEXISTANT_LOCALE; - name = NONEXISTANT_LOCALE; - nameString = ""; - desc = NONEXISTANT_LOCALE; - descString = ""; - marked = false; - inert = false; - directKeyOK = true; - selected_iconName = NULL; - height = 0; - actObserv = NULL; - parent_widget = NULL; - - lcd4l_text = ""; //NI lcd4l-support -} - -void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX) -{ - x = X; - y = Y; - dx = DX; - offx = OFFX; - name_start_x = x + offx + icon_frame_w; - item_color = COL_MENUCONTENT_TEXT; - item_bgcolor = COL_MENUCONTENT_PLUS_0; -} - -void CMenuItem::setActive(const bool Active) -{ - active = current_active = Active; - /* used gets set by the addItem() function. This is for disabling - machine-specific options by just not calling the addItem() function. - Without this, the changeNotifiers would become machine-dependent. */ - if (used && x != -1) - paint(); -} - -bool CMenuItem::initModeCondition(const int& stb_mode) -{ - if (CNeutrinoApp::getInstance()->getMode() == stb_mode){ - active = false; - marked = false; - if (parent_widget) - if (!isSelectable()) - parent_widget->initSelectable(); - return true; - } - printf("\033[33m[CMenuItem] [%s - %d] missmatching stb mode condition %d\033[0m\n", __func__, __LINE__, stb_mode); - return false; -} - -void CMenuItem::disableByCondition(const menu_item_disable_cond_t& condition) -{ - int stb_mode = CNeutrinoApp::getInstance()->getMode(); - - if (condition & DCOND_MODE_TS){ - if (stb_mode == CNeutrinoApp::mode_ts) - if (initModeCondition(stb_mode)) - return; - } - if (condition & DCOND_MODE_RADIO){ - if (stb_mode == CNeutrinoApp::mode_radio) - if (initModeCondition(stb_mode)) - return; - } - if (condition & DCOND_MODE_TV){ - if (stb_mode == CNeutrinoApp::mode_tv) - if (initModeCondition(stb_mode)) - return; - } - - active = current_active; - - if (parent_widget){ - if (!isSelectable()) - parent_widget->initSelectable(); - } -} - -void CMenuItem::setMarked(const bool Marked) -{ - marked = Marked; - if (used && x != -1) - paint(); -} - -void CMenuItem::setInert(const bool Inert) -{ - inert = Inert; - if (used && x != -1) - paint(); -} - -void CMenuItem::setItemButton(const char * const icon_Name, const bool is_select_button) -{ - if (is_select_button) - selected_iconName = icon_Name; - else - iconName = icon_Name; -} - -void CMenuItem::initItemColors(const bool select_mode) -{ - if (select_mode) - { - item_color = COL_MENUCONTENTSELECTED_TEXT; - item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; - } - else if (!active || inert) - { - item_color = COL_MENUCONTENTINACTIVE_TEXT; - item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; - } - else if (marked) - { - item_color = COL_MENUCONTENT_TEXT; - item_bgcolor = COL_MENUCONTENT_PLUS_1; - } - else - { - item_color = COL_MENUCONTENT_TEXT; - item_bgcolor = COL_MENUCONTENT_PLUS_0; - } -} - -void CMenuItem::paintItemCaption(const bool select_mode, const char * right_text, const fb_pixel_t right_bgcol) -{ - int item_height = height; - const char *left_text = getName(); - const char *desc_text = getDescription(); - - if (select_mode) - { - if (right_text && *right_text) - { - ssize_t len = strlen(left_text) + strlen(right_text) + 2; - char str[len]; - snprintf(str, len, "%s %s", left_text, right_text); - CVFD::getInstance()->showMenuText(0, str, -1, true); - //NI lcd4l-support - if(g_settings.lcd4l_support) - lcd4l_text = str; - } - else - { - CVFD::getInstance()->showMenuText(0, left_text, -1, true); - //NI lcd4l-support - if (g_settings.lcd4l_support) - lcd4l_text = left_text; - } - - //NI lcd4l-support - if (g_settings.lcd4l_support) - LCD4l->CreateFile("/tmp/lcd/menu", lcd4l_text, g_settings.lcd4l_convert); - } - - //left text - int _dx = dx; - int icon_w = 0; - int icon_h = 0; - if (iconName_Info_right) { - CFrameBuffer::getInstance()->getIconSize(iconName_Info_right, &icon_w, &icon_h); - if (icon_w) - _dx -= icon_frame_w + icon_w; - } - - int desc_height = 0; - if (desc_text && *desc_text) - desc_height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); - - if (*left_text) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height - desc_height, _dx- (name_start_x - x), left_text, item_color); - - //right text - if (right_text && (*right_text || right_bgcol)) - { - int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text); - int stringstartposOption; - if (*left_text) - stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx - else - stringstartposOption = name_start_x; - if (right_bgcol) { - if (!*right_text) - stringstartposOption -= CFrameBuffer::getInstance()->scale2Res(60); - fb_pixel_t right_frame_col, right_bg_col; - if (active) { - right_bg_col = right_bgcol; - right_frame_col = COL_FRAME_PLUS_0; - } - else { - right_bg_col = COL_MENUCONTENTINACTIVE_TEXT; - right_frame_col = COL_MENUCONTENTINACTIVE_TEXT; - } - CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, NULL, false, right_frame_col, right_bg_col); - col.setFrameThickness(1); //NI - col.setCorner(RADIUS_SMALL); - col.paint(false); - } - if (*right_text) { - stringstartposOption -= (icon_w == 0 ? 0 : icon_w + icon_frame_w); - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height - desc_height, dx- (stringstartposOption- x), right_text, item_color); - } - } - if (desc_text && *desc_text) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->RenderString(name_start_x + OFFSET_INNER_MID, y+ item_height, _dx- OFFSET_INNER_MID - (name_start_x - x), desc_text, item_color); -} - -void CMenuItem::prepareItem(const bool select_mode, const int &item_height) -{ - //set colors - initItemColors(select_mode); - - //paint item background - CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); - frameBuffer->paintBoxRel(x, y, dx, item_height, item_bgcolor, RADIUS_LARGE); -} - -void CMenuItem::paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text, const char * right_text) -{ - CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); - int slider_lenght = 0, h = 0; - frameBuffer->getIconSize(NEUTRINO_ICON_VOLUMEBODY, &slider_lenght, &h); - if(slider_lenght == 0 || factor < optionvalue ) - return; - int stringwidth = 0; - if (right_text != NULL) { - stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("U999"); - } - int stringwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text); - - int maxspace = dx - stringwidth - icon_frame_w - stringwidth2 - OFFSET_INNER_MID; - if(maxspace < slider_lenght) - return ; - - int stringstartposOption = x + dx - stringwidth - slider_lenght; - int optionV = (optionvalue < 0) ? 0 : optionvalue; - frameBuffer->paintBoxRel(stringstartposOption, y, slider_lenght, item_height, item_bgcolor); - frameBuffer->paintIcon(NEUTRINO_ICON_VOLUMEBODY, stringstartposOption, y+2+item_height/4); - frameBuffer->paintIcon(select_mode ? NEUTRINO_ICON_VOLUMESLIDER2BLUE : NEUTRINO_ICON_VOLUMESLIDER2, (stringstartposOption + (optionV * 100 / factor)), y+item_height/4); -} - -void CMenuItem::paintItemButton(const bool select_mode, int item_height, const char * const icon_Name) -{ - item_height -= getDescriptionHeight(); - - CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); - bool selected = select_mode; - bool icon_painted = false; - - const char *icon_name = iconName; - int icon_w = 0; - int icon_h = 0; - - //define icon name depends of numeric value - bool isNumeric = CRCInput::isNumeric(directKey); -#if 0 - if (isNumeric && !g_settings.menu_numbers_as_icons) - icon_name = NULL; -#endif - //define select icon - if (selected && offx > 0) - { - if (selected_iconName) - icon_name = selected_iconName; - else if (!(icon_name && *icon_name) && !isNumeric) - icon_name = icon_Name; - } - - int icon_start_x = x+icon_frame_w; //start of icon space - int icon_space_x = name_start_x - icon_frame_w - icon_start_x; //size of space where to paint icon - int icon_space_mid = icon_start_x + icon_space_x/2; - - //get data of number icon and paint - if (icon_name && *icon_name) - { - if (!active) - icon_name = NEUTRINO_ICON_BUTTON_DUMMY_SMALL; - - frameBuffer->getIconSize(icon_name, &icon_w, &icon_h); - - if (/*active &&*/ icon_w>0 && icon_h>0 && icon_space_x >= icon_w) - { - int icon_x = icon_space_mid - icon_w/2; - int icon_y = y + item_height/2 - icon_h/2; - icon_painted = frameBuffer->paintIcon(icon_name, icon_x, icon_y); - if (icon_painted && (directKey != CRCInput::RC_nokey) && (directKey & CRCInput::RC_Repeat)) { - static int longpress_icon_w = 0, longpress_icon_h = 0; - if (!longpress_icon_w) - frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_LONGPRESS, &longpress_icon_w, &longpress_icon_h); - frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_LONGPRESS, - std::min(icon_x + icon_w - longpress_icon_w/2, name_start_x - longpress_icon_w), - std::min(icon_y + icon_h - longpress_icon_h/2, y + item_height - longpress_icon_h)); - } - } - } - - //paint only number if no icon was painted and keyval is numeric - if (active && isNumeric && !icon_painted) - { - int number_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(CRCInput::getKeyName(directKey)); - - int number_x = icon_space_mid - (number_w/2); - - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(number_x, y+ item_height, item_height, CRCInput::getKeyName(directKey), item_color, item_height); - } - - //get data of number right info icon and paint - if (iconName_Info_right) - { - frameBuffer->getIconSize(iconName_Info_right, &icon_w, &icon_h); - - if (icon_w>0 && icon_h>0) - { - frameBuffer->paintIcon(iconName_Info_right, dx + icon_start_x - (icon_w + 2*OFFSET_INNER_MID), y+ ((item_height/2- icon_h/2)) ); - } - } -} - -void CMenuItem::setIconName() -{ - iconName = NULL; - - switch (directKey & ~CRCInput::RC_Repeat) { - case CRCInput::RC_red: - iconName = NEUTRINO_ICON_BUTTON_RED; - break; - case CRCInput::RC_green: - iconName = NEUTRINO_ICON_BUTTON_GREEN; - break; - case CRCInput::RC_yellow: - iconName = NEUTRINO_ICON_BUTTON_YELLOW; - break; - case CRCInput::RC_blue: - iconName = NEUTRINO_ICON_BUTTON_BLUE; - break; - case CRCInput::RC_standby: - iconName = NEUTRINO_ICON_BUTTON_POWER; - break; - case CRCInput::RC_setup: - iconName = NEUTRINO_ICON_BUTTON_MENU_SMALL; - break; - case CRCInput::RC_help: - iconName = NEUTRINO_ICON_BUTTON_HELP_SMALL; - break; - case CRCInput::RC_info: - iconName = NEUTRINO_ICON_BUTTON_INFO_SMALL; - break; - case CRCInput::RC_pause: //NI - iconName = NEUTRINO_ICON_BUTTON_PAUSE; - break; - case CRCInput::RC_stop: - iconName = NEUTRINO_ICON_BUTTON_STOP; - break; - case CRCInput::RC_0: - iconName = NEUTRINO_ICON_BUTTON_0; - break; - case CRCInput::RC_1: - iconName = NEUTRINO_ICON_BUTTON_1; - break; - case CRCInput::RC_2: - iconName = NEUTRINO_ICON_BUTTON_2; - break; - case CRCInput::RC_3: - iconName = NEUTRINO_ICON_BUTTON_3; - break; - case CRCInput::RC_4: - iconName = NEUTRINO_ICON_BUTTON_4; - break; - case CRCInput::RC_5: - iconName = NEUTRINO_ICON_BUTTON_5; - break; - case CRCInput::RC_6: - iconName = NEUTRINO_ICON_BUTTON_6; - break; - case CRCInput::RC_7: - iconName = NEUTRINO_ICON_BUTTON_7; - break; - case CRCInput::RC_8: - iconName = NEUTRINO_ICON_BUTTON_8; - break; - case CRCInput::RC_9: - iconName = NEUTRINO_ICON_BUTTON_9; - break; - } -} - -void CMenuItem::setName(const std::string& t) -{ - name = NONEXISTANT_LOCALE; - nameString = t; -} - -void CMenuItem::setName(const neutrino_locale_t t) -{ - name = t; - nameString = ""; -} - -const char *CMenuItem::getName(void) -{ - if (name != NONEXISTANT_LOCALE) - return g_Locale->getText(name); - return nameString.c_str(); -} - -void CMenuItem::setDescription(const std::string& t) -{ - desc = NONEXISTANT_LOCALE; - descString = t; - getHeight(); -} - -void CMenuItem::setDescription(const neutrino_locale_t t) -{ - desc = t; - descString = ""; - getHeight(); -} - -const char *CMenuItem::getDescription(void) -{ - if (desc != NONEXISTANT_LOCALE) - return g_Locale->getText(desc); - return descString.c_str(); -} - -int CMenuItem::getDescriptionHeight(void) -{ - if (*getDescription()) - return g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); - return 0; -} - -int CMenuItem::getHeight(void) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight() + getDescriptionHeight(); - return height; -} - -void CMenuItem::activateNotify() -{ - if (actObserv) - actObserv->activateNotify(name); -} - -//small helper class to manage values e.g.: handling needed but deallocated widget objects -CMenuGlobal::CMenuGlobal() -{ - //creates needed select values with default value NO_WIDGET_ID = -1 - for (uint i=0; igetText(Name), Icon, mwidth, w_index); -} - -CMenuWidget::CMenuWidget(const std::string &Name, const std::string & Icon, const int mwidth, const mn_widget_id_t &w_index) -{ - Init(Name, Icon, mwidth, w_index); -} - -void CMenuWidget::Init(const std::string &NameString, const std::string &Icon, const int mwidth, const mn_widget_id_t &w_index) -{ - //pos - x = y = 0; - - //caption and icon - nameString = NameString; - iconfile = Icon; - - //basic attributes - iconOffset = 0; - offx = offy = 0; - from_wizard = SNeutrinoSettings::WIZARD_OFF; - fade = true; - sb_width = 0; - savescreen = false; - preselected = -1; - nextShortcut = 1; - current_page = 0; - has_hints = false; - brief_hints = BRIEF_HINT_NO; - hint_painted = false; - hint_height = 0; - fbutton_count = 0; - fbutton_labels = NULL; - fbutton_width = 0; - fbutton_height = 0; - saveScreen_width = 0; - saveScreen_height = 0; - - //objects - background = NULL; - details_line = NULL; - info_box = NULL; - header = NULL; - frameBuffer = CFrameBuffer::getInstance(); - mglobal = CMenuGlobal::getInstance(); //create CMenuGlobal instance only here - - //handle select values - if(w_index > MN_WIDGET_ID_MAX){ - //error - fprintf(stderr, "Warning: %s Index ID value (%i) is bigger than MN_WIDGET_ID_MAX (%i) \n", __FUNCTION__,w_index,MN_WIDGET_ID_MAX ); - widget_index = NO_WIDGET_ID; - } - else{ - //ok - widget_index = w_index; - } - - //overwrite preselected value with global select value - selected = (widget_index == NO_WIDGET_ID ? preselected : mglobal->v_selected[widget_index]); - - //dimension - mwidth_save = mwidth; - min_width = 0; - width = 0; /* is set in paint() */ - if (mwidth > 100){ - /* warn about abuse until we found all offenders... */ - fprintf(stderr, "Warning: %s (%s) (%s) mwidth over 100%%: %d\n", __FUNCTION__, nameString.c_str(), Icon.c_str(), mwidth); - } - else{ - min_width = frameBuffer->getScreenWidth(true) * mwidth / 100; - if(min_width > (int) frameBuffer->getScreenWidth()) - min_width = frameBuffer->getScreenWidth(); - } -} - -void CMenuWidget::move(int xoff, int yoff) -{ - offx = xoff; - offy = yoff; -} - -CMenuWidget::~CMenuWidget() -{ - resetWidget(true); - ResetModules(); -} - -void CMenuWidget::ResetModules() -{ - if (header){ - header->hide(); - delete header; - header = NULL; - } - if (details_line){ - details_line->hide(); - delete details_line; - details_line = NULL; - } - if (info_box){ - info_box->kill(); - delete info_box; - info_box = NULL; - } -} - -void CMenuWidget::addItem(CMenuItem* menuItem, const bool defaultselected) -{ - if (menuItem->isSelectable()) - { - bool isSelected = defaultselected; - - if (preselected != -1) - isSelected = (preselected == (int)items.size()); - - if (isSelected) - selected = items.size(); - } - - menuItem->isUsed(); - items.push_back(menuItem); - menuItem->setParentWidget(this); -} - -void CMenuWidget::resetWidget(bool delete_items) -{ - for(unsigned int count=0;countisStatic){ - delete item; - item = NULL; - } - } - - items.clear(); - page_start.clear(); - selected=-1; -} - -void CMenuWidget::insertItem(const uint& item_id, CMenuItem* menuItem) -{ - items.insert(items.begin()+item_id, menuItem); -} - -void CMenuWidget::removeItem(const uint& item_id) -{ - items.erase(items.begin()+item_id); - if ((unsigned int) selected >= items.size()) - selected = items.size() - 1; - while (selected > 0 && !items[selected]->active) - selected--; -} - -bool CMenuWidget::hasItem() -{ - return !items.empty(); -} - -int CMenuWidget::getItemId(CMenuItem* menuItem) -{ - for (uint i= 0; i< items.size(); i++) - if (items[i] == menuItem) - return i; - return -1; -} - -CMenuItem* CMenuWidget::getItem(const uint& item_id) -{ - for (uint i= 0; i< items.size(); i++) - if (i == item_id) - return items[i]; - return NULL; -} - -const char *CMenuWidget::getName() -{ - return nameString.c_str(); -} - -int CMenuWidget::exec(CMenuTarget* parent, const std::string &) -{ - neutrino_msg_t msg; - neutrino_msg_data_t data; - bool bAllowRepeatLR = false; - CVFD::MODES oldLcdMode = CVFD::getInstance()->getMode(); - - exit_pressed = false; - - frameBuffer->Lock(); - - if (parent) - parent->hide(); - - COSDFader fader(g_settings.theme.menu_Content_alpha); - if(fade) - fader.StartFadeIn(); - - if(from_wizard) { - for (unsigned int count = 0; count < items.size(); count++) { - if(items[count] == GenericMenuBack) { - items[count] = GenericMenuNext; - break; - } - } - } - - checkHints(); - - if(savescreen) { - calcSize(); - saveScreen(); - } - - /* make sure we start with a selectable item... */ - initSelectable(); - - paint(); - frameBuffer->blit(); - - int pos = selected; - - int retval = menu_return::RETURN_REPAINT; - uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); - - bool bAllowRepeatLR_override = keyActionMap.find(CRCInput::RC_left) != keyActionMap.end() || keyActionMap.find(CRCInput::RC_right) != keyActionMap.end(); - do { - if(hasItem() && selected >= 0 && (int)items.size() > selected ) - bAllowRepeatLR = items[selected]->isMenueOptionChooser(); - bAllowRepeatLR |= bAllowRepeatLR_override; - - g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, bAllowRepeatLR); - - int handled= false; - if ( msg <= CRCInput::RC_MaxRC ) { - timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); - - std::map::iterator it = keyActionMap.find(msg); - if (it != keyActionMap.end()) { - fader.StopFade(); - int rv = it->second.menue->exec(this, it->second.action); - switch ( rv ) { - case menu_return::RETURN_EXIT_ALL: - retval = menu_return::RETURN_EXIT_ALL; - case menu_return::RETURN_EXIT: - msg = CRCInput::RC_timeout; - break; - case menu_return::RETURN_REPAINT: - case menu_return::RETURN_EXIT_REPAINT: - if (fade && washidden) - fader.StartFadeIn(); - checkHints(); - paint(); - break; - } - frameBuffer->blit(); - continue; - } - for (unsigned int i= 0; i< items.size(); i++) { - CMenuItem* titem = items[i]; - if ((titem->directKey != CRCInput::RC_nokey) && (titem->directKey == msg)) { - if (titem->isSelectable()) { - items[selected]->paint( false ); - selected= i; - if (selected > page_start[current_page + 1] || selected < page_start[current_page]) { - /* different page */ - paintItems(); - } - paintHint(selected); - pos = selected; - if (titem->directKeyOK) - msg = CRCInput::RC_ok; - else - msg = CRCInput::RC_nokey; - } else { - // swallow-key... - handled= true; - } - break; - } - } -#if 0 - if (msg == (uint32_t) g_settings.key_pageup) - msg = CRCInput::RC_page_up; - else if (msg == (uint32_t) g_settings.key_pagedown) - msg = CRCInput::RC_page_down; -#endif - } - - if (handled) - continue; - - switch (msg) { - case (NeutrinoMessages::EVT_TIMER): - if(data == fader.GetFadeTimer()) { - if(fader.FadeDone()) - msg = CRCInput::RC_timeout; - } else { - if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { - retval = menu_return::RETURN_EXIT_ALL; - msg = CRCInput::RC_timeout; - } - } - break; - case CRCInput::RC_page_up: - case CRCInput::RC_page_down: - case CRCInput::RC_up: - case CRCInput::RC_down: - case CRCInput::RC_nokey: - { - /* dir and wrap are used when searching for a selectable item: - * if the item is not selectable, try the previous (dir = -1) or - * next (dir = 1) item, until a selectale item is found. - * if wrap = true, allows to wrap around while searching */ - int dir = 1; - bool wrap = false; - switch (msg) { - case CRCInput::RC_nokey: - break; - case CRCInput::RC_page_up: - if (current_page) { - pos = page_start[current_page] - 1; - dir = -1; /* pg_up: search upwards */ - } else - pos = 0; /* ...but not if already at top */ - break; - case CRCInput::RC_page_down: - pos = page_start[current_page + 1]; - if (pos >= (int)items.size()) { - pos = items.size() - 1; - dir = -1; /* if last item is not selectable, go up */ - } - break; - case CRCInput::RC_up: - dir = -1; - default: /* fallthrough or RC_down => dir = 1 */ - pos += dir; - if (pos < 0 || pos >= (int)items.size()) - pos -= dir * items.size(); - wrap = true; - } - if (!items.empty() && pos >= (int)items.size()) - pos = (int)items.size() - 1; - do { - if(items.empty()) - break; - CMenuItem* item = items[pos]; - if (item->isSelectable()) { - if (pos < page_start[current_page + 1] && pos >= page_start[current_page]) { - /* in current page */ - items[selected]->paint(false); - item->activateNotify(); - item->paint(true); - paintHint(pos); - selected = pos; - } else { - /* different page */ - selected = pos; - paintItems(); - } - break; - } - pos += dir; - if (wrap && (pos >= (int)items.size() || pos < 0)) { - pos -= dir * items.size(); - wrap = false; /* wrap only once, avoids endless loop */ - } - } while (pos >= 0 && pos < (int)items.size()); - break; - } - case (CRCInput::RC_left): - { - if(hasItem() && selected > -1 && (int)items.size() > selected) { - CMenuItem* itemX = items[selected]; - if (!itemX->isMenueOptionChooser()) { - if (g_settings.menu_left_exit) - msg = CRCInput::RC_timeout; - break; - } - } - } - case (CRCInput::RC_right): - case (CRCInput::RC_ok): - { - if(hasItem() && selected > -1 && (int)items.size() > selected) { - //NI lcd4l-support - LCD4l->RemoveFile("/tmp/lcd/menu"); - - //exec this item... - CMenuItem* item = items[selected]; - if (!item->isSelectable()) - break; - item->msg = msg; - fader.StopFade(); - int rv = item->exec( this ); - - //NI lcd4l-support - if (g_settings.lcd4l_support) - LCD4l->CreateFile("/tmp/lcd/menu", item->lcd4l_text, g_settings.lcd4l_convert); - - switch ( rv ) { - case menu_return::RETURN_EXIT_ALL: - retval = menu_return::RETURN_EXIT_ALL; - case menu_return::RETURN_EXIT: - msg = CRCInput::RC_timeout; - break; - case menu_return::RETURN_REPAINT: - case menu_return::RETURN_EXIT_REPAINT: - if (fade && washidden) - fader.StartFadeIn(); - checkHints(); - pos = selected; - paint(); - break; - } - } else - msg = CRCInput::RC_timeout; - } - break; - - case (CRCInput::RC_home): - exit_pressed = true; - msg = CRCInput::RC_timeout; - break; - case (CRCInput::RC_timeout): - break; - case (CRCInput::RC_setup): - //close any menu on menu-key - { - msg = CRCInput::RC_timeout; - retval = menu_return::RETURN_EXIT_ALL; - } - break; - case (CRCInput::RC_help): - // FIXME should we switch hints in menu without hints ? - checkHints(); - if (has_hints) - hide(); - g_settings.show_menu_hints = !g_settings.show_menu_hints; - if (has_hints) - paint(); - break; - - default: - if (CNeutrinoApp::getInstance()->listModeKey(msg)) { - g_RCInput->postMsg (msg, 0); - retval = menu_return::RETURN_EXIT_ALL; - msg = CRCInput::RC_timeout; - } - else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { - retval = menu_return::RETURN_EXIT_ALL; - msg = CRCInput::RC_timeout; - } - } - if(msg == CRCInput::RC_timeout) { - if(fade && fader.StartFadeOut()) { - timeoutEnd = CRCInput::calcTimeoutEnd( 1 ); - msg = 0; - continue; - } - } - - if ( msg <= CRCInput::RC_MaxRC ) - { - // recalculate timeout for RC-keys - timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); - } - frameBuffer->blit(); - } - while ( msg!=CRCInput::RC_timeout ); - hide(); - if (background) { - delete[] background; - background = NULL; - } - - fader.StopFade(); - - if(!parent) - if(oldLcdMode != CVFD::getInstance()->getMode()) - CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); - - //NI lcd4l-support - LCD4l->RemoveFile("/tmp/lcd/menu"); - - for (unsigned int count = 0; count < items.size(); count++) - { - if(items[count] == GenericMenuNext) - items[count] = GenericMenuBack; - else if (items[count] == GenericMenuCancel) - items[count] = GenericMenuBack; - } - - if (widget_index > -1) - mglobal->v_selected[widget_index] = selected; - - frameBuffer->Unlock(); - return retval; -} - -void CMenuWidget::integratePlugins(CPlugins::i_type_t integration, const unsigned int shortcut, bool enabled) -{ - bool separatorline = false; - unsigned int number_of_plugins = (unsigned int) g_Plugins->getNumberOfPlugins(); - unsigned int sc = shortcut; - for (unsigned int count = 0; count < number_of_plugins; count++) - { - if ((g_Plugins->getIntegration(count) == integration) && !g_Plugins->isHidden(count)) - { - if (!separatorline) - { - addItem(GenericMenuSeparatorLine); - separatorline = true; - } - printf("[neutrino] integratePlugins: add %s\n", g_Plugins->getName(count)); - neutrino_msg_t dk = (shortcut != CRCInput::RC_nokey) ? CRCInput::convertDigitToKey(sc++) : CRCInput::RC_nokey; - CMenuForwarder *fw_plugin = new CMenuForwarder(g_Plugins->getName(count), enabled, NULL, CPluginsExec::getInstance(), to_string(count).c_str(), dk); - fw_plugin->setHint(g_Plugins->getHintIcon(count), g_Plugins->getDescription(count)); - addItem(fw_plugin); - } - } -} - -void CMenuWidget::hide() -{ - if(savescreen && background) - restoreScreen();//FIXME - else { - if (header) - header->kill(); - if (info_box) - info_box->kill(); - if (details_line) - details_line->hide(); - frameBuffer->paintBackgroundBoxRel(x, y, full_width, full_height + fbutton_height); - //paintHint(-1); - } - paintHint(-1); - frameBuffer->blit(); - - /* setActive() paints item for hidden parent menu, if called from child menu */ - for (unsigned int count = 0; count < items.size(); count++) - items[count]->init(-1, 0, 0, 0); - hint_painted = false; - washidden = true; - if (CInfoClock::getInstance()->isRun()) - CInfoClock::getInstance()->enableInfoClock(!CInfoClock::getInstance()->isBlocked()); - OnAfterHide(); -} - -void CMenuWidget::checkHints() -{ - brief_hints = (brief_hints || (from_wizard == SNeutrinoSettings::WIZARD_START)); - - GenericMenuBack->setHint("", NONEXISTANT_LOCALE); - GenericMenuNext->setHint("", NONEXISTANT_LOCALE); - for (unsigned int i= 0; i< items.size(); i++) { - if(items[i]->hintIcon || items[i]->hint != NONEXISTANT_LOCALE || !items[i]->hintText.empty()) { - has_hints = true; - break; - } - } - if (has_hints) { - GenericMenuBack->setHint(NEUTRINO_ICON_HINT_BACK, brief_hints ? LOCALE_MENU_HINT_BACK_BRIEF : LOCALE_MENU_HINT_BACK); - GenericMenuNext->setHint(NEUTRINO_ICON_HINT_NEXT, brief_hints ? LOCALE_MENU_HINT_NEXT_BRIEF : LOCALE_MENU_HINT_NEXT); - } -} - -void CMenuWidget::calcSize() -{ - // recalc min_width - min_width = 0; - int mwidth = std::min(mwidth_save, 100); - min_width = frameBuffer->getScreenWidth(true) * mwidth / 100; - if (min_width > (int)frameBuffer->getScreenWidth()) - min_width = frameBuffer->getScreenWidth(); - - width = min_width; - - int wi, hi; - for (unsigned int i= 0; i< items.size(); i++) { - wi = 0; - if (items[i]->iconName_Info_right) { - frameBuffer->getIconSize(items[i]->iconName_Info_right, &wi, &hi); - if ((wi > 0) && (hi > 0)) - wi += OFFSET_INNER_MID; - else - wi = 0; - } - int tmpw = items[i]->getWidth() + 2*OFFSET_INNER_MID + wi; /* 10 pixels to the left and right of the text */ - if (tmpw > width) - width = tmpw; - } - hint_height = 0; - if(g_settings.show_menu_hints && has_hints) { - int lines = 2; - int text_height = 2*OFFSET_INNER_MID + lines*g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT]->getHeight(); - /* assuming all hint icons has the same size ! */ - int icon_width, icon_height; - frameBuffer->getIconSize(NEUTRINO_ICON_HINT_TVMODE, &icon_width, &icon_height); - icon_height += 2*OFFSET_INNER_MID; - hint_height = std::max(icon_height, text_height); - } - /* set the max height to 9/10 of usable screen height - debatable, if the callers need a possibility to set this */ - height = (frameBuffer->getScreenHeight() - fbutton_height - hint_height) / 20 * 18; /* make sure its a multiple of 2 */ - - if(height > ((int)frameBuffer->getScreenHeight() - OFFSET_INNER_MID)) - height = frameBuffer->getScreenHeight() - OFFSET_INNER_MID; - - int neededWidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(getName()); - if (neededWidth > width - frameBuffer->scale2Res(48)) { - width = neededWidth + frameBuffer->scale2Res(48)+1; - } - hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); - - int heightCurrPage=0; - page_start.clear(); - page_start.push_back(0); - total_pages=1; - - int maxItemHeight = 0; - - for (unsigned int i= 0; i< items.size(); i++) { - int item_height=items[i]->getHeight(); - heightCurrPage+=item_height; - if(heightCurrPage > (height-hheight)) { - page_start.push_back(i); - total_pages++; - maxItemHeight = std::max(heightCurrPage - item_height, maxItemHeight); - heightCurrPage=item_height; - } - } - maxItemHeight = std::max(heightCurrPage, maxItemHeight); - page_start.push_back(items.size()); - - iconOffset= 0; - for (unsigned int i= 0; i< items.size(); i++) - if (items[i]->iconName /*&& !g_settings.menu_numbers_as_icons*/) - { - int w, h; - frameBuffer->getIconSize(items[i]->iconName, &w, &h); - if (w > iconOffset) - iconOffset = w; - } - - iconOffset += OFFSET_INNER_MID; - width += iconOffset; - - if (fbutton_count) - width = std::max(width, fbutton_width); - - if (width > (int)frameBuffer->getScreenWidth()) - width = frameBuffer->getScreenWidth(); - - // shrink menu if less items - height = std::min(height, hheight + maxItemHeight); - - //scrollbar width - sb_width=0; - if(total_pages > 1) - sb_width=SCROLLBAR_WIDTH; - - full_width = /*DETAILSLINE_WIDTH+*/width+sb_width+OFFSET_SHADOW; - full_height = height+RADIUS_LARGE+OFFSET_SHADOW*2 /*+hint_height+OFFSET_INTER*/; - /* + DETAILSLINE_WIDTH for the hintbox connection line - * + center_offset for symmetry - * + 20 for setMenuPos calculates 10 pixels border left and right */ - int center_offset = (g_settings.menu_pos == MENU_POS_CENTER) ? DETAILSLINE_WIDTH : 0; - int max_possible = (int)frameBuffer->getScreenWidth() - DETAILSLINE_WIDTH - center_offset - 2*OFFSET_INNER_MID; - if (full_width > max_possible) - { - width = max_possible - sb_width - OFFSET_SHADOW; - full_width = max_possible + center_offset; /* symmetry in MENU_POS_CENTER case */ - } - - setMenuPos(full_width); -} - -void CMenuWidget::initSelectable() -{ - int pos = 0; - if (selected > 0 && selected < (int)items.size()) - pos = selected; - else - selected = -1; - - while (pos < (int)items.size()) { - if (items[pos]->isSelectable()) - break; - pos++; - } - selected = pos; -} - -void CMenuWidget::paint() -{ - if (header){ - if ((bool)header->getCornerRadius() != (bool)g_settings.rounded_corners) //ensure reset if corner mode was changed - ResetModules(); - } - - if (CInfoClock::getInstance()->isRun()) - CInfoClock::getInstance()->disableInfoClock(); - calcSize(); - CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 /*, nameString.c_str()*/); - - OnBeforePaint(); - - // paint head - if (header == NULL){ - header = new CComponentsHeader(x, y, width + sb_width, hheight, getName(), iconfile); - header->enableShadow(CC_SHADOW_RIGHT | CC_SHADOW_CORNER_TOP_RIGHT | CC_SHADOW_CORNER_BOTTOM_RIGHT); - header->setOffset(OFFSET_INNER_MID); - } - header->setCaption(getName()); - header->setColorAll(COL_FRAME_PLUS_0, COL_MENUHEAD_PLUS_0, COL_SHADOW_PLUS_0); - header->setCaptionColor(COL_MENUHEAD_TEXT); - header->enableColBodyGradient(g_settings.theme.menu_Head_gradient, COL_MENUCONTENT_PLUS_0); - header->enableGradientBgCleanUp(savescreen); - header->paint(CC_SAVE_SCREEN_NO); - - // paint body shadow - frameBuffer->paintBoxRel(x+OFFSET_SHADOW, y + hheight + OFFSET_SHADOW, width + sb_width, height - hheight + RADIUS_LARGE + (fbutton_count ? fbutton_height : 0), COL_SHADOW_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); - // paint body background - frameBuffer->paintBoxRel(x, y+hheight, width + sb_width, height-hheight + RADIUS_LARGE, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, (fbutton_count ? CORNER_NONE : CORNER_BOTTOM)); - - item_start_y = y+hheight; - paintItems(); - washidden = false; - if (fbutton_count) - ::paintButtons(x, y + height + RADIUS_LARGE, width + sb_width, fbutton_count, fbutton_labels, width, fbutton_height); -} - -void CMenuWidget::setMenuPos(const int& menu_width) -{ - int scr_x = frameBuffer->getScreenX(); - int scr_y = frameBuffer->getScreenY(); - int scr_w = frameBuffer->getScreenWidth(); - int scr_h = frameBuffer->getScreenHeight(); - int real_h = full_height + fbutton_height + hint_height; - int x_old = x; - int y_old = y; - //configured positions - switch(g_settings.menu_pos) - { - case MENU_POS_CENTER: - x = offx + scr_x + ((scr_w - menu_width ) >> 1 ); - y = offy + scr_y + ((scr_h - real_h) >> 1 ); - x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI - break; - - case MENU_POS_TOP_LEFT: - y = offy + scr_y + OFFSET_INNER_MID; - x = offx + scr_x + OFFSET_INNER_MID; - x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI - break; - - case MENU_POS_TOP_RIGHT: - y = offy + scr_y + OFFSET_INNER_MID; - x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; - break; - - case MENU_POS_BOTTOM_LEFT: - y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; - x = offx + scr_x + OFFSET_INNER_MID; - x += g_settings.show_menu_hints_line ? DETAILSLINE_WIDTH : 0; //NI - break; - - case MENU_POS_BOTTOM_RIGHT: - y = /*offy +*/ scr_y + scr_h - real_h - OFFSET_INNER_MID; - x = /*offx +*/ scr_x + scr_w - menu_width - OFFSET_INNER_MID; - break; - } - if (x_old != x || y_old != y) - ResetModules(); -} - -void CMenuWidget::paintItems() -{ - //Item not currently on screen - if (selected >= 0) - { - while (current_page > 0 && selected < page_start[current_page]) - current_page--; - while (current_page+1 < page_start.size() && selected >= page_start[current_page + 1]) - current_page++; - } - - // Scrollbar - if(total_pages>1) - { - int item_height=height-(item_start_y-y); - paintScrollBar(x+ width, item_start_y, sb_width, item_height, total_pages, current_page); - /* background of menu items, paint every time because different items can have - * different height and this might leave artifacts otherwise after changing pages */ - frameBuffer->paintBoxRel(x,item_start_y, width,item_height, COL_MENUCONTENT_PLUS_0); - } - - int ypos=item_start_y; - for (int count = 0; count < (int)items.size(); count++) - { - CMenuItem* item = items[count]; - item->OnPaintItem(); - if ((count >= page_start[current_page]) && - (count < page_start[current_page + 1])) - { - item->init(x, ypos, width, iconOffset); - if (item->isSelectable() && selected == -1) - selected = count; - - if (selected == count) { - item->activateNotify(); - paintHint(count); - } - ypos = item->paint(selected == count); - } - else - { - /* x = -1 is a marker which prevents the item from being painted on setActive changes */ - item->init(-1, 0, 0, 0); - } - } -} - -/*adds the typical menu intro with optional subhead, separator, back or cancel button and separatorline to menu*/ -void CMenuWidget::addIntroItems(neutrino_locale_t subhead_text, neutrino_locale_t section_text, int buttontype, bool brief_hint) -{ - brief_hints = brief_hint; - - if (subhead_text != NONEXISTANT_LOCALE) - addItem(new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING, subhead_text)); - - addItem(GenericMenuSeparator); - - switch (buttontype) { - case BTN_TYPE_BACK: - GenericMenuBack->setItemButton(!g_settings.menu_left_exit ? NEUTRINO_ICON_BUTTON_HOME : NEUTRINO_ICON_BUTTON_LEFT); - addItem(GenericMenuBack); - break; - case BTN_TYPE_CANCEL: - addItem(GenericMenuCancel); - break; - case BTN_TYPE_NEXT: - addItem(GenericMenuNext); - break; - } - - if (section_text != NONEXISTANT_LOCALE) - addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, section_text)); - else if (buttontype != BTN_TYPE_NO) - addItem(GenericMenuSeparatorLine); -} - -void CMenuWidget::saveScreen() -{ - if(!savescreen) - return; - - delete[] background; - saveScreen_height = full_height+fbutton_height; - saveScreen_width = full_width; - saveScreen_y = y; - saveScreen_x = x; - background = new fb_pixel_t [saveScreen_height * saveScreen_width]; - if(background) - frameBuffer->SaveScreen(saveScreen_x /*-DETAILSLINE_WIDTH*/, saveScreen_y, saveScreen_width, saveScreen_height, background); -} - -void CMenuWidget::restoreScreen() -{ - if(background) { - if(savescreen) - frameBuffer->RestoreScreen(saveScreen_x /*-DETAILSLINE_WIDTH*/, saveScreen_y, saveScreen_width, saveScreen_height, background); - } -} - -void CMenuWidget::enableSaveScreen(bool enable) -{ - savescreen = enable; - if (!enable && background) { - delete[] background; - background = NULL; - saveScreen_width = 0; - saveScreen_height = 0; - saveScreen_y = 0; - saveScreen_x = 0; - } -} - -void CMenuWidget::paintHint(int pos) -{ - if (!g_settings.show_menu_hints){ - ResetModules(); //ensure clean up on changed setting - return; - } - - if (pos < 0 && !hint_painted) - return; - - if (hint_painted) { - /* clear detailsline line */ - if (details_line) - details_line->hide(); - /* clear info box */ - if ((info_box) && ((pos < 0) || savescreen)) - savescreen ? info_box->hide() : info_box->kill(); - if (info_box) - hint_painted = info_box->isPainted(); - } - if (pos < 0) - return; - - CMenuItem* item = items[pos]; - - if (!item->hintIcon && item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) { - if (info_box) { - savescreen ? info_box->hide() : info_box->kill(); - hint_painted = info_box->isPainted(); - if (details_line) - details_line->hide(); - } - return; - } - - if (item->hint == NONEXISTANT_LOCALE && item->hintText.empty()) - item->hintText = " "; - - int iheight = item->getHeight(); - int rad = RADIUS_LARGE; - int xpos = x - DETAILSLINE_WIDTH; - int ypos2 = y + height + fbutton_height + rad + OFFSET_SHADOW + OFFSET_INTER; - int iwidth = width+sb_width; - - //init details line and infobox dimensions - int ypos1 = item->getYPosition(); - int ypos1a = ypos1 + (iheight/2); - int ypos2a = ypos2 + (hint_height/2); - int markh = hint_height > rad*2 ? hint_height - rad*2 : hint_height; - int imarkh = iheight/2; - - //init details line - if (details_line == NULL) - details_line = new CComponentsDetailsLine(); - - details_line->setXPos(xpos); - details_line->setYPos(ypos1a); - details_line->setYPosDown(ypos2a); - details_line->setHMarkTop(imarkh); - details_line->setHMarkDown(markh); - details_line->syncSysColors(); - - //init infobox - std::string str = item->hintText.empty() ? g_Locale->getText(item->hint) : item->hintText; - if (info_box == NULL) - info_box = new CComponentsInfoBox(); - - info_box->setDimensionsAll(x, ypos2, iwidth, hint_height); - info_box->setFrameThickness(g_settings.show_menu_hints_line ? 1 : 0); //NI - //NI info_box->removeLineBreaks(str); - info_box->setText(str, CTextBox::AUTO_WIDTH, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_HINT], COL_MENUCONTENT_TEXT); - info_box->setCorner(RADIUS_LARGE); - info_box->setColorAll(COL_FRAME_PLUS_0, COL_MENUCONTENTDARK_PLUS_0); - info_box->setTextColor(COL_MENUCONTENTDARK_TEXT); - info_box->enableShadow(); - info_box->setPicture(item->hintIcon ? item->hintIcon : ""); - info_box->enableColBodyGradient(g_settings.theme.menu_Hint_gradient, COL_MENUFOOT_PLUS_0, g_settings.theme.menu_Hint_gradient_direction);// COL_MENUFOOT_PLUS_0 is default footer color - - //paint result - if (details_line) - details_line->paint(); - if (info_box) - info_box->paint(savescreen); - - hint_painted = info_box ? info_box->isPainted() : false; -} - -void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::string & action) -{ - keyActionMap[key].menue = menue; - keyActionMap[key].action = action; -} - -void CMenuWidget::setFooter(const struct button_label *_fbutton_labels, const int _fbutton_count, bool repaint) -{ - fbutton_count = _fbutton_count; - fbutton_labels = _fbutton_labels; - - fbutton_width = 0; - fbutton_height = 0; - if (fbutton_count) - paintButtons(fbutton_labels, fbutton_count, 0, 0, 0, 0, 0, false, &fbutton_width, &fbutton_height); - if (repaint) - paint(); -} - - -//------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionNumberChooser::CMenuOptionNumberChooser( const neutrino_locale_t Name, int * const OptionValue, const bool Active, - const int min_value, const int max_value, - CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, - const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init(Name, "", OptionValue, min_value, max_value, print_offset, special_value, special_value_name, Observ, sliderOn); -} - -CMenuOptionNumberChooser::CMenuOptionNumberChooser( const std::string &Name, int * const OptionValue, const bool Active, - const int min_value, const int max_value, - CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const char * const IconName, - const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init(NONEXISTANT_LOCALE, Name, OptionValue, min_value, max_value, print_offset, special_value, special_value_name, Observ, sliderOn); -} - -void CMenuOptionNumberChooser::init( const neutrino_locale_t& lName, - const std::string &sName, - int* const Option_Value, - const int& min_value, - const int& max_value, - const int& print_offset, - const int& special_value, - const neutrino_locale_t& special_value_name, - CChangeObserver * const Observ, - bool sliderOn) -{ - name = lName; - nameString = sName; - optionValue = Option_Value; - lower_bound = min_value; - upper_bound = max_value; - display_offset = print_offset; - localized_value = special_value; - localized_value_name = special_value_name; - observ = Observ; - slider_on = sliderOn; - - numberFormat = "%d"; - numberFormatFunction = NULL; - directKeyOK = false; - numeric_input = false; -} - -int CMenuOptionNumberChooser::exec(CMenuTarget*) -{ - int res = menu_return::RETURN_NONE; - - if(msg == CRCInput::RC_left) { - if (((*optionValue) > upper_bound) || ((*optionValue) <= lower_bound)) - *optionValue = upper_bound; - else - (*optionValue)--; - } else if (numeric_input && msg == CRCInput::RC_ok) { - int size = 0; - int b = lower_bound; - if (b < 0) { - size++, - b = -b; - } - if (b < upper_bound) - b = upper_bound; - for (; b; b /= 10, size++); - CIntInput cii(name, optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); - cii.exec(NULL, ""); - if (*optionValue > upper_bound) - *optionValue = upper_bound; - else if (*optionValue < lower_bound) - *optionValue = lower_bound; - res = menu_return::RETURN_REPAINT; - } else { - if (((*optionValue) >= upper_bound) || ((*optionValue) < lower_bound)) - *optionValue = lower_bound; - else - (*optionValue)++; - } - - bool wantsRepaint = false; - if(observ && !luaAction.empty()) { - // optionValue is int* - wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str()); - } else if(observ) - wantsRepaint = observ->changeNotify(name, optionValue); - - // give the observer a chance to modify the value - paint(true); - OnAfterChangeOption(); - if (wantsRepaint) - res = menu_return::RETURN_REPAINT; - - return res; -} - -int CMenuOptionNumberChooser::paint(bool selected) -{ - const char * l_option; - char option_value[40]; - - if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value)) - { - if (numberFormatFunction) { - std::string s = numberFormatFunction(*optionValue + display_offset); - strncpy(option_value, s.c_str(), sizeof(option_value)); - } else - sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset); - l_option = option_value; - } - else - l_option = g_Locale->getText(localized_value_name); - - //paint item - prepareItem(selected, height); - - //paint item icon - paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); - if(slider_on) - paintItemSlider(selected, height, *optionValue, (upper_bound - lower_bound), getName(), l_option); - //paint text - paintItemCaption(selected, l_option); - - return y+height; -} - -int CMenuOptionNumberChooser::getWidth(void) -{ - int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); - int _lower_bound = lower_bound; - int _upper_bound = upper_bound; - int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth(); - - int w1 = 0; - if (_lower_bound < 0) - w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-"); - while (_lower_bound) { - w1 += m; - _lower_bound /= 10; - } - - int w2 = 0; - if (_upper_bound < 0) - w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-"); - while (_upper_bound) { - w1 += m; - _upper_bound /= 10; - } - - width += (w1 > w2) ? w1 : w2; - - if (numberFormatFunction) { - std::string s = numberFormatFunction(0); - width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); // arbitrary - } else if (numberFormat != "%d") { - char format[numberFormat.length()]; - snprintf(format, numberFormat.length(), numberFormat.c_str(), 0); - width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0"); - } - - width += OFFSET_INNER_MID; /* min 10 pixels between option name and value. enough? */ - - const char *desc_text = getDescription(); - if (*desc_text) - width = std::max(width, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); - return width; -} - -CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init("", OptionName, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); -} - -CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const size_t Number_Of_Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init(OptionName, NONEXISTANT_LOCALE, OptionValue, Options, NULL, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); -} - -CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init("", OptionName, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); -} - -CMenuOptionChooser::CMenuOptionChooser( const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, const size_t Number_Of_Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, Options, NULL, Number_Of_Options, Observ, Pulldown, OptionsSort); -} - -CMenuOptionChooser::CMenuOptionChooser( const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init("", OptionName, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort); -} - -CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector &Options, - const bool Active, CChangeObserver * const Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown, bool OptionsSort) - : CAbstractMenuOptionChooser(Active, DirectKey, IconName) -{ - init(OptionName, NONEXISTANT_LOCALE, OptionValue, NULL, NULL, &Options, Options.size(), Observ, Pulldown, OptionsSort); -} - -CMenuOptionChooser::~CMenuOptionChooser() -{ - clearChooserOptions(); -} - -void CMenuOptionChooser::init( const std::string &OptionName, - const neutrino_locale_t Name, - int * const OptionValue, - const struct keyval * const Options, - const struct keyval_ext * const OptionsExt, - std::vector * v_Options, - const size_t Number_Of_Options, - CChangeObserver * const Observ, - bool Pulldown, - bool OptionsSort) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - nameString = OptionName; - name = Name; - optionValue = OptionValue; - number_of_options = Number_Of_Options; - observ = Observ; - pulldown = Pulldown; - optionsSort = OptionsSort; - - if (Options || OptionsExt) - { - if (Options) - { - for (unsigned int i = 0; i < number_of_options; i++) - { - struct keyval_ext opt; - opt = Options[i]; - options.push_back(opt); - } - } - - if (OptionsExt) - { - for (unsigned int i = 0; i < number_of_options; i++) - options.push_back(OptionsExt[i]); - } - } - else{ - if (v_Options) - options = *v_Options; - } -} - -void CMenuOptionChooser::clearChooserOptions() -{ - for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) - delete *it; - - option_chooser_options_v.clear(); -} - -void CMenuOptionChooser::setOptions(const struct keyval * const Options, const unsigned Number_Of_Options) -{ - options.clear(); - number_of_options = Number_Of_Options; - for (unsigned int i = 0; i < number_of_options; i++) - { - struct keyval_ext opt; - opt = Options[i]; - options.push_back(opt); - } - if (used && x != -1) - paint(false); -} - -void CMenuOptionChooser::setOptions(const struct keyval_ext * const Options, const unsigned Number_Of_Options) -{ - options.clear(); - number_of_options = Number_Of_Options; - for (unsigned int i = 0; i < number_of_options; i++) - options.push_back(Options[i]); - if (used && x != -1) - paint(false); -} - -void CMenuOptionChooser::setOption(const int newvalue) -{ - *optionValue = newvalue; -} - -int CMenuOptionChooser::getOption(void) const -{ - return *optionValue; -} - - -int CMenuOptionChooser::exec(CMenuTarget*) -{ - bool wantsRepaint = false; - int ret = menu_return::RETURN_NONE; - char *optionValname = NULL; - - if (optionsSort) { - optionsSort = false; - clearChooserOptions(); - unsigned int i1; - for (i1 = 0; i1 < number_of_options; i1++) - { - CMenuOptionChooserOptions* co = new CMenuOptionChooserOptions(); - co->key = options[i1].key; - co->valname = (options[i1].valname != 0) ? options[i1].valname : g_Locale->getText(options[i1].value); - option_chooser_options_v.push_back(co); - } - - sort(option_chooser_options_v.begin(), option_chooser_options_v.end(), CMenuOptionChooserCompareItem()); - - options.clear(); - for (std::vector::iterator it = option_chooser_options_v.begin(); it != option_chooser_options_v.end(); ++it) { - struct keyval_ext opt; - opt.key = (*it)->key; - opt.value = NONEXISTANT_LOCALE; - opt.valname = (*it)->valname.c_str(); - options.push_back(opt); - } - } - - if((msg == CRCInput::RC_ok) && pulldown) { - int select = -1; - CMenuWidget* menu = new CMenuWidget(getName(), NEUTRINO_ICON_SETTINGS); - menu->enableFade(false); - /* FIXME: BACK button with hints enabled - parent menu getting holes, possible solution - * to hide parent, or add hints ? */ - menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); - // menu->move(20, 0); - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - for(unsigned int count = 0; count < number_of_options; count++) - { - bool selected = false; - const char * l_option; - if (options[count].key == (*optionValue)) - selected = true; - - if(options[count].valname != 0) - l_option = options[count].valname; - else - l_option = g_Locale->getText(options[count].value); - CMenuForwarder *mn_option = new CMenuForwarder(l_option, true, NULL, selector, to_string(count).c_str()); - mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); - menu->addItem(mn_option, selected); - } - menu->exec(NULL, ""); - ret = menu_return::RETURN_REPAINT;; - if(select >= 0) - { - *optionValue = options[select].key; - optionValname = (char *) options[select].valname; - } - delete menu; - delete selector; - } else { - for(unsigned int count = 0; count < number_of_options; count++) { - if (options[count].key == (*optionValue)) { - if(msg == CRCInput::RC_left) { - if(count > 0) - optionValname = (char *) options[(count-1) % number_of_options].valname, - *optionValue = options[(count-1) % number_of_options].key; - else - optionValname = (char *) options[number_of_options-1].valname, - *optionValue = options[number_of_options-1].key; - } else - optionValname = (char *) options[(count+1) % number_of_options].valname, - *optionValue = options[(count+1) % number_of_options].key; - break; - } - } - } - paint(true); - OnAfterChangeOption(); - if(observ && !luaAction.empty()) { - if (optionValname) - wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname); - } else if(observ) - wantsRepaint = observ->changeNotify(name, optionValue); - - if (wantsRepaint) - ret = menu_return::RETURN_REPAINT; - - return ret; -} - -int CMenuOptionChooser::paint( bool selected) -{ - neutrino_locale_t option = NONEXISTANT_LOCALE; - const char * l_option = NULL; - - for(unsigned int count = 0 ; count < number_of_options; count++) { - if (options[count].key == *optionValue) { - option = options[count].value; - if(options[count].valname != 0) - l_option = options[count].valname; - else - l_option = g_Locale->getText(option); - break; - } - } - - if(l_option == NULL) - { - *optionValue = options[0].key; - option = options[0].value; - if(options[0].valname != 0) - l_option = options[0].valname; - else - l_option = g_Locale->getText(option); - } - - //paint item - prepareItem(selected, height); - - //paint item icon - paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); - - //paint text - paintItemCaption(selected, l_option); - - return y+height; -} - -int CMenuOptionChooser::getWidth(void) -{ - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); - int width = tw; - - for(unsigned int count = 0; count < options.size(); count++) { - int ow = 0; - if (options[count].valname) - ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(options[count].valname); - else - ow = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(options[count].value)); - - if (tw + ow > width) - width = tw + ow; - } - - width += OFFSET_INNER_MID; /* min 10 pixels between option name and value. enough? */ - const char *desc_text = getDescription(); - if (*desc_text) - width = std::max(width, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); - return width; -} - -//------------------------------------------------------------------------------------------------------------------------------- - -CMenuOptionStringChooser::CMenuOptionStringChooser( const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) - : CMenuItem(Active, DirectKey, IconName) -{ - init("", OptionName, OptionValue, Observ, Pulldown); -} - -CMenuOptionStringChooser::CMenuOptionStringChooser( const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, - const neutrino_msg_t DirectKey, const char * const IconName, bool Pulldown) - : CMenuItem(Active, DirectKey, IconName) -{ - init(OptionName, NONEXISTANT_LOCALE, OptionValue, Observ, Pulldown); -} - -void CMenuOptionStringChooser::init( const std::string &OptionName, - const neutrino_locale_t Name, - std::string* pOptionValue, - CChangeObserver * const Observ, - bool Pulldown) -{ - nameString = OptionName; - name = Name; - optionValuePtr = pOptionValue ? pOptionValue : &optionValue; - observ = Observ; - pulldown = Pulldown; -} - - -CMenuOptionStringChooser::~CMenuOptionStringChooser() -{ - options.clear(); -} - -void CMenuOptionStringChooser::setTitle(std::string &Title) -{ - title = Title; -} - -void CMenuOptionStringChooser::setTitle(const neutrino_locale_t Title) -{ - title = g_Locale->getText(Title); -} - -void CMenuOptionStringChooser::addOption(const std::string &value) -{ - options.push_back(value); -} - -void CMenuOptionStringChooser::sortOptions() -{ - sort(options.begin(), options.end()); -} - -int CMenuOptionStringChooser::exec(CMenuTarget* parent) -{ - bool wantsRepaint = false; - int ret = menu_return::RETURN_NONE; - - if((!parent || msg == CRCInput::RC_ok) && pulldown) { - int select = -1; - - if (parent) - parent->hide(); - - std::string title_str = title.empty() ? getName() : title; - - CMenuWidget* menu = new CMenuWidget(title_str, NEUTRINO_ICON_SETTINGS); - menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); - //if(parent) menu->move(20, 0); - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - for(unsigned int count = 0; count < options.size(); count++) - { - bool selected = optionValuePtr && (options[count] == *optionValuePtr); - CMenuForwarder *mn_option = new CMenuForwarder(options[count], true, NULL, selector, to_string(count).c_str()); - mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); - menu->addItem(mn_option, selected); - } - menu->exec(NULL, ""); - ret = menu_return::RETURN_REPAINT; - if(select >= 0 && optionValuePtr) - *optionValuePtr = options[select]; - delete menu; - delete selector; - } else { - //select next value - for(unsigned int count = 0; count < options.size(); count++) { - if (optionValuePtr && (options[count] == *optionValuePtr)) { - if(msg == CRCInput::RC_left) { - if(count > 0) - *optionValuePtr = options[(count - 1) % options.size()]; - else - *optionValuePtr = options[options.size() - 1]; - } else - *optionValuePtr = options[(count + 1) % options.size()]; - //wantsRepaint = true; - break; - } - } - - paint(true); - } - if(observ && !luaAction.empty()) - wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValuePtr ? optionValuePtr->c_str() : "")); - else if(observ) { - wantsRepaint = observ->changeNotify(name, (void *)(optionValuePtr ? optionValuePtr->c_str() : "")); - } - if (wantsRepaint) - ret = menu_return::RETURN_REPAINT; - - return ret; -} - -int CMenuOptionStringChooser::paint( bool selected ) -{ - //paint item - prepareItem(selected, height); - - //paint item icon - paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); - - //paint text - paintItemCaption(selected, optionValuePtr->c_str()); - - return y+height; -} - -//------------------------------------------------------------------------------------------------------------------------------- -CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) -{ - init("", Text, Option, NULL, Target, ActionKey); -} - -CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) -{ - init(Text, NONEXISTANT_LOCALE, Option, NULL, Target, ActionKey); -} - -CMenuForwarder::CMenuForwarder( const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) -{ - init("", Text, "", Option, Target, ActionKey); -} - -CMenuForwarder::CMenuForwarder( const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, - neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) - : CMenuItem(Active, DirectKey, IconName, IconName_Info_right, IsStatic) -{ - init(Text, NONEXISTANT_LOCALE, "", Option, Target, ActionKey); -} - -void CMenuForwarder::init( const std::string &Text, - const neutrino_locale_t Name, - const std::string &sOption, - const char * const cOption, - CMenuTarget* Target, - const char * const ActionKey) -{ - nameString = Text; - name = Name; - - if (sOption.empty()) - { - option_string = cOption ? cOption : ""; - option_string_ptr = &option_string; - } - else - option_string_ptr = &sOption; - - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; -} - -void CMenuForwarder::setOption(const std::string &Option) -{ - option_string = Option; - option_string_ptr = &option_string; -} - -int CMenuForwarder::getWidth(void) -{ - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); - - fb_pixel_t bgcol = 0; - std::string option_name = getOption(); - if (jumpTarget) - bgcol = jumpTarget->getColor(); - - if (!option_name.empty()) - tw += OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name); - else if (bgcol) - tw += OFFSET_INNER_MID + CFrameBuffer::getInstance()->scale2Res(60); - - const char *desc_text = getDescription(); - if (*desc_text) - tw = std::max(tw, OFFSET_INNER_MID + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(desc_text)); - return tw; -} - -int CMenuForwarder::exec(CMenuTarget* parent) -{ - if(jumpTarget) - return jumpTarget->exec(parent, actionKey); - return menu_return::RETURN_EXIT; -} - -std::string CMenuForwarder::getOption(void) -{ - if (!option_string_ptr->empty()) - return *option_string_ptr; - if (jumpTarget) - return jumpTarget->getValue(); - return ""; -} - -int CMenuForwarder::paint(bool selected) -{ - std::string option_name = getOption(); - - fb_pixel_t bgcol = 0; - if (jumpTarget) - bgcol = jumpTarget->getColor(); - - //paint item - prepareItem(selected, height); - - //paint icon - paintItemButton(selected, height); - - //caption - paintItemCaption(selected, option_name.c_str(), bgcol); - - return y+ height; -} - -//------------------------------------------------------------------------------------------------------------------------------- -CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) -{ - init(Type, Text, ""); -} - -CMenuSeparator::CMenuSeparator(const int Type, const std::string &Text, bool IsStatic) : CMenuItem(false, CRCInput::RC_nokey, NULL, NULL, IsStatic) -{ - init(Type, NONEXISTANT_LOCALE, Text); -} - -void CMenuSeparator::init(const int& Type, const neutrino_locale_t& lText, const std::string &sText) -{ - type = Type; - name = lText; - nameString = sText; -} - -int CMenuSeparator::getHeight(void) -{ - if (nameString.empty() && name == NONEXISTANT_LOCALE) - return OFFSET_INNER_MID; - return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); -} - -int CMenuSeparator::getWidth(void) -{ - int w = 0; - if (type & LINE) - w = 2*OFFSET_INNER_MID; /* offset left and right */ - const char *l_name = getName(); - if ((type & STRING) && *l_name) - w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); - return w; -} - -int CMenuSeparator::paint(bool selected) -{ - height = getHeight(); - CFrameBuffer * frameBuffer = CFrameBuffer::getInstance(); - - if ((type & SUB_HEAD)) - { - item_color = COL_MENUHEAD_TEXT; - item_bgcolor = g_settings.theme.menu_Head_gradient ? COL_MENUCONTENT_PLUS_0 : COL_MENUHEAD_PLUS_0; - } - else - { - item_color = COL_MENUCONTENTINACTIVE_TEXT; - item_bgcolor = COL_MENUCONTENT_PLUS_0; - } - - frameBuffer->paintBoxRel(x,y, dx, height, item_bgcolor); - if ((type & LINE)) - { - int grad = g_settings.theme.menu_Separator_gradient_enable ? CC_COLGRAD_COL_DARK_LIGHT_DARK : CC_COLGRAD_OFF; - paintBoxRel(x+OFFSET_INNER_MID, y+(height>>1), dx-2*OFFSET_INNER_MID, 1, COL_MENUCONTENT_PLUS_1, 0, CORNER_NONE, grad, COL_MENUCONTENT_PLUS_0, CFrameBuffer::gradientHorizontal, CColorGradient::light); - } - if ((type & STRING)) - { - const char * l_name = getName(); - - if (*l_name) - { - int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name); - int iconwidth, iconheight; - CFrameBuffer::getInstance()->getIconSize(NEUTRINO_ICON_BUTTON_HOME, &iconwidth, &iconheight); - - /* if no alignment is specified, align centered */ - if (type & ALIGN_LEFT) - name_start_x = x + (!(type & SUB_HEAD) ? name_start_x : 2*OFFSET_INNER_MID + iconwidth); - else if (type & ALIGN_RIGHT) - name_start_x = x + dx - stringwidth - 2*OFFSET_INNER_MID; - else /* ALIGN_CENTER */ - name_start_x = x + (dx >> 1) - (stringwidth >> 1); - - frameBuffer->paintBoxRel(name_start_x-OFFSET_INNER_SMALL, y, stringwidth+2*OFFSET_INNER_SMALL, height, item_bgcolor); - - if ((type & LINE)) //NI - use COL_MENUHEAD_TEXT for CMenuSeparators defined with LINE and STRING - item_color = COL_MENUHEAD_TEXT; - - paintItemCaption(selected); - } - } - return y+ height; -} - -bool CPINProtection::check() -{ - hint = NONEXISTANT_LOCALE; - std::string cPIN; - do - { - cPIN = ""; - CPINInput* PINInput = new CPINInput(title, &cPIN, 4, hint); - PINInput->exec( getParent(), ""); - delete PINInput; - hint = LOCALE_PINPROTECTION_WRONGCODE; - } while ((cPIN != *validPIN) && !cPIN.empty()); - return (cPIN == *validPIN); -} - - -bool CZapProtection::check() -{ - hint = NONEXISTANT_LOCALE; - int res; - std::string cPIN; - do - { - cPIN = ""; - - CPLPINInput* PINInput = new CPLPINInput(title, &cPIN, 4, hint, fsk); - - res = PINInput->exec(getParent(), ""); - delete PINInput; - if (!access(CONFIGDIR "/pinentered.sh", X_OK)) { - std::string systemstr = CONFIGDIR "/pinentered.sh " + cPIN; - system(systemstr.c_str()); - } - hint = LOCALE_PINPROTECTION_WRONGCODE; - } while ( (cPIN != *validPIN) && !cPIN.empty() && - ( res == menu_return::RETURN_REPAINT ) && - ( fsk >= g_settings.parentallock_lockage ) ); - return ( (cPIN == *validPIN) || - ( fsk < g_settings.parentallock_lockage ) ); -} - -int CLockedMenuForwarder::exec(CMenuTarget* parent) -{ - Parent = parent; - - if (Ask && !check()) - { - Parent = NULL; - return menu_return::RETURN_REPAINT; - } - - Parent = NULL; - return CMenuForwarder::exec(parent); -} - -int CMenuSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & actionKey) -{ - if (!actionKey.empty()) - *m_select = atoi(actionKey); - else - *m_select = -1; - return menu_return::RETURN_EXIT; -} - -CMenuProgressbar::CMenuProgressbar(const neutrino_locale_t Text) : CMenuItem(true, CRCInput::RC_nokey, NULL, NULL, false) -{ - init(Text, ""); -} - -CMenuProgressbar::CMenuProgressbar(const std::string &Text) : CMenuItem(true, CRCInput::RC_nokey, NULL, NULL, false) -{ - init(NONEXISTANT_LOCALE, Text); -} - -void CMenuProgressbar::init(const neutrino_locale_t Loc, const std::string &Text) -{ - name = Loc; - nameString = Text; - scale.setDimensionsAll(0, 0, 100, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight()/2); - scale.setValues(100, 100); -} - -int CMenuProgressbar::paint(bool selected) -{ - //paint item - prepareItem(selected, height); - - //left text - const char *left_text = getName(); - int _dx = dx; - - if (*left_text) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y + height, _dx- (name_start_x - x), left_text, item_color); - - //progress bar - int pb_x; - if (*left_text) - pb_x = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text) + icon_frame_w, x + dx - scale.getWidth() - icon_frame_w); - else - pb_x = name_start_x; - - scale.setPos(pb_x, y + (height - scale.getHeight())/2); - scale.reset(); - scale.paint(); - - return y + height; -} - -int CMenuProgressbar::getHeight(void) -{ - return std::max(CMenuItem::getHeight(), scale.getHeight()); -} - -int CMenuProgressbar::getWidth(void) -{ - int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName()); - if (width) - width += OFFSET_INNER_MID; - return width + scale.getWidth(); -} - -int CMenuProgressbar::exec(CMenuTarget*) -{ - int val = scale.getValue() + 25; - if (val > 100) - val = 0; - scale.setValue(val); - scale.reset(); - scale.paint(); - return menu_return::RETURN_NONE; -}