summaryrefslogtreecommitdiff
path: root/plugins/osdserver
diff options
context:
space:
mode:
authorroot <root@elwms02.(none)>2010-04-06 16:13:08 +0200
committerroot <root@elwms02.(none)>2010-04-06 16:13:08 +0200
commit0e7005fcc7483c01aa102fbea358c5ac65a48d62 (patch)
tree11517ce0d3d2977c6732b3aa583b0008083e0bd3 /plugins/osdserver
downloadx-vdr-0e7005fcc7483c01aa102fbea358c5ac65a48d62.tar.gz
x-vdr-0e7005fcc7483c01aa102fbea358c5ac65a48d62.tar.bz2
hello world
Diffstat (limited to 'plugins/osdserver')
-rw-r--r--plugins/osdserver/file-browser.sh160
-rw-r--r--plugins/osdserver/plugin.sh51
2 files changed, 211 insertions, 0 deletions
diff --git a/plugins/osdserver/file-browser.sh b/plugins/osdserver/file-browser.sh
new file mode 100644
index 0000000..f5142af
--- /dev/null
+++ b/plugins/osdserver/file-browser.sh
@@ -0,0 +1,160 @@
+#!/bin/bash
+# file-browser.sh - Version 0.0.2
+# A small file-browser for the vdr-osdserver
+
+if [ "$*" != "0" ] && [ -x "$*" ] && [ -d "$*" ]; then
+ directory=$(echo "$*" | sed s?//?/?g)
+else
+ directory="/"
+fi
+exit_cmd=
+svdrpsend="svdrpsend.pl"
+
+mkfifo --mode=700 /tmp/pipe-in$$ /tmp/pipe-out$$
+exec 3<> /tmp/pipe-in$$
+exec 4<> /tmp/pipe-out$$
+rm /tmp/pipe-in$$ /tmp/pipe-out$$
+
+{ netcat localhost 2010 ; echo 499 disconnected ; } <&3 >&4 &
+pid=$!
+
+
+function error() {
+ SendCmd Quit
+
+ exec 3>&-
+ exec 4>&-
+
+ kill $pid
+
+ exit 1
+}
+
+function ReadReply() {
+ reply2xx=()
+ reply3xx=()
+ reply4xx=()
+
+ while read -r code line <&4 ; do
+ echo "< $code $line"
+ case $code in
+ 2*) IFS=$' \t\n\r' reply2xx=($code "$line")
+ ;;
+ 3*) IFS=$' \t\n\r' reply3xx=($code $line)
+ ;;
+ 4*) IFS=$' \t\n\r' reply4xx=($code "$line")
+ ;;
+ esac
+ [ -n "${reply2xx[0]}" ] && break;
+ done
+
+ [ -n "${reply4xx[0]}" ] && return 1
+ return 0
+}
+
+function SendCmd() {
+ echo "> $*"
+ echo "$*" >&3
+
+ ReadReply
+}
+
+function FileBrowser() {
+ n=1 # counter reset
+ # menu
+ SendCmd "menu=NewMenu \"File-Browser: $directory\"" || return 1
+ if [ "$directory" != "/" ] ; then
+ SendCmd "opt${n}=menu.AddOsdItem \".\"" || return 1
+ ((n=n+1))
+ SendCmd "opt${n}=menu.AddOsdItem \"..\"" || return 1
+ ((n=n+1))
+ fi
+ files=$(ls -I $(basename $0) -B "$directory")
+ if [ -n "$files" ] ; then
+ for i in $files ; do
+ SendCmd "opt$n=menu.AddOsdItem \"$i\"" || return 1
+ ((n=n+1))
+ done
+ fi
+
+ SendCmd 'menu.Show' || return 1
+ SendCmd 'menu.EnableEvent keyOk close' || return 1
+ SendCmd 'menu.SleepEvent' || return 1
+
+ # reply
+ if [ "${reply3xx[0]}" != "300" ] ; then return 1 ; fi
+
+ if [ "${reply3xx[2]}" == "close" ] ; then
+ if [ "$directory" != "/" ] ; then
+ exit_cmd="$0 \"$(dirname "$directory")\""
+ else
+ SendCmd 'Message "Closing File-Browser ..."' || return 1
+ fi
+
+ SendCmd 'menu.SendState osEnd' || return 1
+ return 0
+ fi
+
+ if [ "${reply3xx[2]}" != "keyOk" ] ; then return 1 ; fi
+
+ SendCmd 'menu.GetCurrent' || return 1
+ if [ "${reply3xx[0]}" != "302" ] ; then return 1 ; fi
+
+ # options
+ n=1
+ if [ "$directory" != "/" ] ; then
+ if [ "${reply3xx[2]}" == "opt${n}" ] ; then
+ exit_cmd="$0 /"
+ SendCmd 'menu.SendState osEnd' || return 1
+ return 0
+ fi
+ ((n=n+1))
+
+ if [ "${reply3xx[2]}" == "opt${n}" ] ; then
+ exit_cmd="$0 \"$(dirname "$directory")\""
+ SendCmd 'menu.SendState osEnd' || return 1
+ return 0
+ fi
+ ((n=n+1))
+ fi
+
+ if [ -n "$files" ] ; then
+ for i in $files ; do
+ if [ "${reply3xx[2]}" == "opt${n}" ] ; then
+ if [ -d "${directory}/${i}" ] ; then
+ exit_cmd="$0 \"${directory}/${i}\""
+ break
+ elif [ -f "${directory}/${i}" ] && [ -x "${directory}/${i}" ] ; then
+ SendCmd "Message \"Executing $i ...\""
+ exit_cmd="${directory}/${i}"
+ break
+ elif [ -f "${directory}/${i}" ] && [ -r "${directory}/${i}" ] ; then
+ SendCmd "Message \"Not supported: $i\""
+# exit_cmd="${directory}/${i}"
+ break
+ else
+ SendCmd "Message \"Not supported: $i\""
+ break
+ fi
+ else
+ ((n=n+1))
+ fi
+ done
+ fi
+
+ SendCmd 'menu.SendState osEnd' || return 1
+ return 0
+}
+
+
+ReadReply
+SendCmd 'Version 0' || error
+
+FileBrowser || error
+
+SendCmd Quit
+
+exec 3>&-
+exec 4>&-
+
+eval $exit_cmd
diff --git a/plugins/osdserver/plugin.sh b/plugins/osdserver/plugin.sh
new file mode 100644
index 0000000..8570eb9
--- /dev/null
+++ b/plugins/osdserver/plugin.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# x-vdr (Installations-Skript fuer einen VDR mit Debian als Basis)
+# von Marc Wernecke - www.zulu-entertainment.de
+# 08.01.2009
+#
+# vdr-osdserver
+
+# defaults
+source ./../../x-vdr.conf
+source ./../../setup.conf
+source ./../../functions
+WEB="http://www.udo-richter.de/vdr/files/vdr-osdserver-0.1.2.tgz"
+VERSION="osdserver-0.1.2"
+LINK="osdserver"
+
+VAR=`basename $WEB`
+DIR=`pwd`
+
+# plugin entfernen
+function clean_plugin() {
+ cd $SOURCEDIR/VDR/PLUGINS/src
+ rm -rf $LINK*
+ rm -f $VDRLIBDIR/libvdr-$LINK*
+ log "cleaning $LINK"
+}
+
+# plugin installieren
+function install_plugin() {
+ download_plugin
+ extract_plugin
+ cd $SOURCEDIR/VDR/PLUGINS/src
+ rm -f $LINK
+ ln -vfs $VERSION $LINK
+ patch_plugin
+
+ ## plugin specials - start ##
+
+ ## plugin specials - ende ##
+}
+
+# plugin commands
+if [ $# \> 0 ]; then
+ cmd=$1
+ cmd_plugin
+else
+ install_plugin
+ log "install-plugin fuer $VERSION ist fertig"
+fi
+
+exit 0