summaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2003-01-06 14:44:27 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2003-01-06 14:44:27 +0100
commit4e15f6d658139fca773b76088bf1523839c20ffd (patch)
tree6d51dd4546800274eeddace2069fe08837186076 /menu.c
parent43b582a04d3b77c0f0f92284bdccbbad190f9d41 (diff)
downloadvdr-4e15f6d658139fca773b76088bf1523839c20ffd.tar.gz
vdr-4e15f6d658139fca773b76088bf1523839c20ffd.tar.bz2
Implemented 'Link Layer' based CAM support
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c173
1 files changed, 172 insertions, 1 deletions
diff --git a/menu.c b/menu.c
index 68fe3b97..ce56ba0d 100644
--- a/menu.c
+++ b/menu.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.c 1.229 2002/12/22 12:40:43 kls Exp $
+ * $Id: menu.c 1.230 2003/01/06 13:35:38 kls Exp $
*/
#include "menu.h"
@@ -1521,6 +1521,117 @@ eOSState cMenuCommands::ProcessKey(eKeys Key)
return state;
}
+// --- cMenuCam --------------------------------------------------------------
+
+cMenuCam::cMenuCam(cCiMenu *CiMenu)
+:cOsdMenu("")
+{
+ ciMenu = CiMenu;
+ selected = false;
+ if (ciMenu->Selectable())
+ SetHasHotkeys();
+ SetTitle(ciMenu->TitleText() ? ciMenu->TitleText() : "CAM");
+ for (int i = 0; i < ciMenu->NumEntries(); i++)
+ Add(new cOsdItem(hk(ciMenu->Entry(i))));
+ //XXX implement a clean way of displaying this:
+ Add(new cOsdItem(ciMenu->SubTitleText()));
+ Add(new cOsdItem(ciMenu->BottomText()));
+ Display();
+}
+
+cMenuCam::~cMenuCam()
+{
+ if (!selected)
+ ciMenu->Cancel();
+ delete ciMenu;
+}
+
+eOSState cMenuCam::Select(void)
+{
+ if (ciMenu->Selectable()) {
+ ciMenu->Select(Current());
+ selected = true;
+ return osEnd;
+ }
+ return osContinue;
+}
+
+eOSState cMenuCam::ProcessKey(eKeys Key)
+{
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk: return Select();
+ default: break;
+ }
+ }
+ return state;
+}
+
+// --- cMenuCamEnquiry -------------------------------------------------------
+
+//XXX this is just quick and dirty - make this a separate display object
+cMenuCamEnquiry::cMenuCamEnquiry(cCiEnquiry *CiEnquiry)
+:cOsdMenu("")
+{
+ ciEnquiry = CiEnquiry;
+ replied = false;
+ SetTitle(ciEnquiry->Text() ? ciEnquiry->Text() : "CAM");
+ Display();
+}
+
+cMenuCamEnquiry::~cMenuCamEnquiry()
+{
+ if (!replied)
+ ciEnquiry->Cancel();
+ delete ciEnquiry;
+}
+
+eOSState cMenuCamEnquiry::Reply(void)
+{
+ ciEnquiry->Reply("1234");//XXX implement actual user input
+ replied = true;
+ return osEnd;
+}
+
+eOSState cMenuCamEnquiry::ProcessKey(eKeys Key)
+{
+ eOSState state = cOsdMenu::ProcessKey(Key);
+
+ if (state == osUnknown) {
+ switch (Key) {
+ case kOk: return Reply();
+ default: break;
+ }
+ }
+ return state;
+}
+
+// --- CamControl ------------------------------------------------------------
+
+cOsdObject *CamControl(void)
+{
+ for (int d = 0; d < cDevice::NumDevices(); d++) {
+ cDevice *Device = cDevice::GetDevice(d);
+ if (Device) {
+ cCiHandler *CiHandler = Device->CiHandler();
+ if (CiHandler) {
+ CiHandler->Process();
+ cCiMenu *CiMenu = CiHandler->GetMenu();
+ if (CiMenu)
+ return new cMenuCam(CiMenu);
+ else {
+ cCiEnquiry *CiEnquiry = CiHandler->GetEnquiry();
+ if (CiEnquiry)
+ return new cMenuCamEnquiry(CiEnquiry);
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
// --- cMenuRecordingItem ----------------------------------------------------
class cMenuRecordingItem : public cOsdItem {
@@ -1950,6 +2061,12 @@ eOSState cMenuSetupLNB::ProcessKey(eKeys Key)
// --- cMenuSetupCICAM -------------------------------------------------------
class cMenuSetupCICAM : public cMenuSetupBase {
+private:
+ int helpKeys;
+ void SetHelpKeys(void);
+ cCiHandler *GetCurrentCiHandler(void);
+ eOSState Menu(void);
+ eOSState Reset(void);
public:
cMenuSetupCICAM(void);
virtual eOSState ProcessKey(eKeys Key);
@@ -1957,6 +2074,7 @@ public:
cMenuSetupCICAM::cMenuSetupCICAM(void)
{
+ helpKeys = -1;
SetSection(tr("CICAM"));
for (int d = 0; d < cDevice::NumDevices(); d++) {
for (int i = 0; i < 2; i++) {
@@ -1965,6 +2083,46 @@ cMenuSetupCICAM::cMenuSetupCICAM(void)
Add(new cMenuEditCaItem(buffer, &data.CaCaps[d][i]));
}
}
+ SetHelpKeys();
+}
+
+cCiHandler *cMenuSetupCICAM::GetCurrentCiHandler(void)
+{
+ cDevice *Device = cDevice::GetDevice(Current() / 2);
+ return Device ? Device->CiHandler() : NULL;
+}
+
+void cMenuSetupCICAM::SetHelpKeys(void)
+{
+ int NewHelpKeys = helpKeys;
+ NewHelpKeys = GetCurrentCiHandler() ? 1 : 0;
+ if (NewHelpKeys != helpKeys) {
+ switch (NewHelpKeys) {
+ case 0: SetHelp(NULL); break;
+ case 1: SetHelp(tr("Menu"), tr("Reset"));
+ }
+ helpKeys = NewHelpKeys;
+ }
+}
+
+eOSState cMenuSetupCICAM::Menu(void)
+{
+ cCiHandler *CiHandler = GetCurrentCiHandler();
+ if (CiHandler && CiHandler->EnterMenu())
+ return osEnd; // the CAM menu will be executed explicitly from the main loop
+ else
+ Interface->Error(tr("Can't open CAM menu!"));
+ return osContinue;
+}
+
+eOSState cMenuSetupCICAM::Reset(void)
+{
+ cCiHandler *CiHandler = GetCurrentCiHandler();
+ if (CiHandler && CiHandler->Reset())
+ Interface->Info(tr("CAM has been reset"));
+ else
+ Interface->Error(tr("Can't reset CAM!"));
+ return osContinue;
}
eOSState cMenuSetupCICAM::ProcessKey(eKeys Key)
@@ -1973,6 +2131,19 @@ eOSState cMenuSetupCICAM::ProcessKey(eKeys Key)
if (state == osBack && Key == kOk)
cDevice::SetCaCaps();
+ else if (state == osUnknown) {
+ switch (Key) {
+ case kRed: if (helpKeys == 1)
+ return Menu();
+ break;
+ case kGreen: if (helpKeys == 1)
+ return Reset();
+ break;
+ default: break;
+ }
+ }
+ if (Key != kNone)
+ SetHelpKeys();
return state;
}