2 ###############################################################################
4 ###############################################################################
5 # Copyright (C) 1998-2008 VideoLAN
8 # Authors: Christophe Massiot <massiot@via.ecp.fr>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 ###############################################################################
32 if test x
"$1" != x
"-r" -o -z "$2"; then
33 echo "Usage: $0 -r <remote socket> [<slot 0-n>]" >&2
40 if which dvblastctl
>/dev
/null
; then
41 DVBLASTCTL
="dvblastctl -r $SOCKET"
42 elif test -x "$PWD/dvblastctl"; then
43 DVBLASTCTL
="$PWD/dvblastctl -r $SOCKET"
44 elif test -x "$BASE_DIR/dvblastctl"; then
45 DVBLASTCTL
="$BASE_DIR/dvblastctl -r $SOCKET"
47 echo "Couldn't find dvblastctl"
53 # Check adapter status
56 $DVBLASTCTL mmi_status
>/dev
/null
59 if test $NUM_SLOTS -eq 255; then
60 echo "Unable to set up a connection" >&2
63 if test $NUM_SLOTS -eq 0; then
64 echo "Adapter has no available CAM module" >&2
67 if test -z $SLOT; then
68 echo "Defaulting to slot #0"
71 if test "$SLOT" -ge $NUM_SLOTS; then
72 echo "Slot out of range, pick in the range 0-`expr $NUM_SLOTS - 1`" >&2
81 $DVBLASTCTL mmi_slot_status
$SLOT >/dev
/null
84 if test $STATUS -ne 0; then
85 echo "Slot is not ready, retry later" >&2
89 $DVBLASTCTL mmi_get
$SLOT >/dev
/null
92 if test $STATUS -eq 255; then
93 echo "Opening MMI session..."
94 $DVBLASTCTL mmi_open
$SLOT
96 if test $STATUS -eq 255; then
97 echo "Communication error" >&2
99 elif test $STATUS -ne 0; then
100 echo "Couldn't open MMI session" >&2
112 $DVBLASTCTL mmi_get
$SLOT
117 echo "Connection closed" >&2
121 echo -n "Your choice (empty for extra choices) ? "
124 echo "CAUTION: the password won't be bulleted, be alone"
125 echo -n "Your choice (empty for extra choices) ? "
132 echo -n "Your choice: (B)ack, (C)lose or (R)etry ? "
135 echo -n "Your choice: [0-$STATUS], (C)lose or (R)etry ? "
143 if test -z "$ANSWER"; then
144 echo -n "(B)ack, (C)lose or (R)etry ? "
149 if ! $DVBLASTCTL mmi_send_text
$SLOT; then
150 echo "mmi_send_text failed, apparently" >&2
155 C|c|Close|close|CLOSE
)
156 $DVBLASTCTL mmi_close
$SLOT
159 R|r|Retry|retry|RETRY
)
163 echo "Invalid string, retry..."
168 if ! $DVBLASTCTL mmi_send_text
$SLOT "$ANSWER"; then
169 echo "mmi_send_text failed, apparently" >&2
179 if ! $DVBLASTCTL mmi_send_choice
$SLOT 0; then
180 echo "mmi_send_choice failed, apparently" >&2
185 C|c|Close|close|CLOSE
)
186 $DVBLASTCTL mmi_close
$SLOT
189 R|r|Retry|retry|RETRY
)
193 echo "$ANSWER" |
grep -q "^[[:digit:]]\+\$"
194 if test $?
-ne 0; then
195 echo "Invalid string, retry..."
197 if ! $DVBLASTCTL mmi_send_choice
$SLOT "$ANSWER"; then
198 echo "mmi_send_choice failed, apparently" >&2