Skip to content

Commit

Permalink
[CI] Possibility to disable operator profiles for CI+ module (#3983)
Browse files Browse the repository at this point in the history
thanks @DimitarCC
  • Loading branch information
Dima73 committed May 17, 2024
1 parent fdf554c commit 0f4e056
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 39 deletions.
4 changes: 4 additions & 0 deletions lib/dvb_ci/dvbci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,6 +1275,10 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr):
user_mapped = false;
plugged = false;
m_ci_version = versionUnknown;
char config_key_operator_profile[255];
snprintf(config_key_operator_profile, 255, "config.ci.%d.disable_operator_profile", slotid);
bool operator_profile_disabled = eConfigManager::getConfigBoolValue(config_key_operator_profile, false);
m_operator_profiles_disabled = operator_profile_disabled;
snprintf(configStr, 255, "config.ci.%d.enabled", slotid);
bool enabled = eConfigManager::getConfigBoolValue(configStr, true);
if (enabled)
Expand Down
2 changes: 2 additions & 0 deletions lib/dvb_ci/dvbci.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class eDVBCISlot: public iObject, public sigc::trackable
int m_tunernum;
eMainloop *m_context;
int m_ciplus_routing_tunernum;
bool m_operator_profiles_disabled;
std::string m_ciplus_routing_input;
std::string m_ciplus_routing_ci_input;

Expand Down Expand Up @@ -129,6 +130,7 @@ class eDVBCISlot: public iObject, public sigc::trackable
int getSlotID();
int getNumOfServices();
int getVersion();
bool getIsOperatorProfileDisabled() { return m_operator_profiles_disabled; };
int16_t getCADemuxID() { return m_ca_demux_id; };
int getTunerNum() { return m_tunernum; };
int getUseCount() { return use_count; };
Expand Down
36 changes: 33 additions & 3 deletions lib/dvb_ci/dvbci_resmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,42 @@ int eDVBCIResourceManagerSession::doAction()
// {0x00, 0x60, 0x60, 0x03},
// {0x00, 0x04, 0x10, 0x01},
};
const unsigned char data_v2_no_operator[][4]=
{
{0x00, 0x01, 0x00, 0x41}, // res mgr 1
// {0x00, 0x01, 0x00, 0x42}, // res mgr 2
{0x00, 0x02, 0x00, 0x41}, // app mgr 1
{0x00, 0x02, 0x00, 0x42}, // app mgr 2
{0x00, 0x02, 0x00, 0x43}, // app mgr 3
{0x00, 0x02, 0x00, 0x45}, // app mgr 5
{0x00, 0x03, 0x00, 0x41}, // ca mgr
{0x00, 0x20, 0x00, 0x41}, // host ctrl 1
{0x00, 0x20, 0x00, 0x42}, // host ctrl 2
{0x00, 0x20, 0x00, 0x43}, // host ctrl 3
{0x00, 0x24, 0x00, 0x41}, // datetime
{0x00, 0x40, 0x00, 0x41}, // mmi
// {0x00, 0x10, 0x00, 0x41},
{0x00, 0x41, 0x00, 0x41}, // app mmi 1
{0x00, 0x41, 0x00, 0x42}, // app mmi 2
{0x00, 0x8c, 0x10, 0x01}, // content ctrl 1
{0x00, 0x8c, 0x10, 0x02}, // content ctrl 2
{0x00, 0x8c, 0x10, 0x04}, // content ctrl 4
{0x00, 0x8d, 0x10, 0x01}, // Host lang ctrl
{0x00, 0x8e, 0x10, 0x01}, // Cam upgrade
// {0x00, 0x8f, 0x10, 0x01}, // operator profile 1
// {0x00, 0x8f, 0x10, 0x02}, // operator profile 2
// {0x00, 0x97, 0x10, 0x01},
// {0x00, 0x60, 0x60, 0x03},
// {0x00, 0x04, 0x10, 0x01},
};

bool operator_profile_disabled = slot->getIsOperatorProfileDisabled();

bool ciplus = ciplus_cert_param_files_exists();
const void *p = ciplus ? data_v2 : data;
int len = ciplus ? sizeof(data_v2) : sizeof(data);
const void *p = ciplus ? (operator_profile_disabled ? data_v2_no_operator : data_v2) : data;
int len = ciplus ? (operator_profile_disabled ? sizeof(data_v2_no_operator) : sizeof(data_v2)) : sizeof(data);
sendAPDU(tag, p, len);
state=stateFinal;
state = stateFinal;
return 0;
}
case stateFinal:
Expand Down
25 changes: 0 additions & 25 deletions lib/mmi/mmi_ui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <lib/mmi/mmi_ui.h>
#include <lib/dvb_ci/dvbci_session.h> // for parseLengthField

#include <regex>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
Expand All @@ -20,7 +19,6 @@ eMMI_UI::eMMI_UI(int max_slots)
slotdata[i].mmiScreenReady=0;
slotdata[i].mmiTuplePos=0;
slotdata[i].state=-1;
slotdata[i].isError10=0;
}
}

Expand Down Expand Up @@ -89,7 +87,6 @@ int eMMI_UI::processMMIData(int slot_id, const unsigned char *tag, const void *d
unsigned char *d=(unsigned char*)data;
unsigned char *max=((unsigned char*)d) + len;
int pos = 0;
bool isError10 = false;
eDebug("[eMMI_UI] Tmenu_last");
if (d > max)
break;
Expand Down Expand Up @@ -118,16 +115,10 @@ int eMMI_UI::processMMIData(int slot_id, const unsigned char *tag, const void *d
memcpy(str, ((unsigned char*)d), textlen);
str[textlen] = '\0';
std::string converted_str = convertDVBUTF8(str, textlen, -1, 1, 0);
if (std::regex_match(converted_str, std::regex("^[^0-9]*\\s10")))
isError10 = true;
mmiScreenAddText(slot_id, pos++, (char*)converted_str.c_str());
eDebug("[eMMI_UI] %s", converted_str.c_str());
d += textlen;
}

if (isError10) {
mmiScreenError10(slot_id);
}

mmiScreenFinish(slot_id);
break;
Expand Down Expand Up @@ -194,13 +185,6 @@ int eMMI_UI::availableMMI(int slot)
return false;
}

int eMMI_UI::isError10(int slot)
{
if (slot < m_max_slots)
return slotdata[slot].isError10;
return false;
}

int eMMI_UI::mmiScreenClose(int slot, int timeout)
{
if (slot >= m_max_slots)
Expand All @@ -223,15 +207,6 @@ int eMMI_UI::mmiScreenClose(int slot, int timeout)
return 0;
}

int eMMI_UI::mmiScreenError10(int slot)
{
if (slot < m_max_slots) {
slotdata[slot].isError10 = 1;
stateChanged(slot);
}
return 0;
}

int eMMI_UI::mmiScreenEnq(int slot, int blind, int answerLen, char *text)
{
if (slot >= m_max_slots)
Expand Down
3 changes: 0 additions & 3 deletions lib/mmi/mmi_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ struct slot_ui_data
ePyObject mmiScreen;
int mmiTuplePos;
int mmiScreenReady;
int isError10;
};
#endif

Expand Down Expand Up @@ -46,7 +45,6 @@ class eMMI_UI: public sigc::trackable
virtual int getMMIState(int slot)=0;
#endif
int availableMMI(int slot);
int isError10(int slot);
PyObject *getMMIScreen(int slot);
#ifndef SWIG
int processMMIData(int slot, const unsigned char *tag, const void *data, int len);
Expand All @@ -55,7 +53,6 @@ class eMMI_UI: public sigc::trackable
int mmiScreenBegin(int slot, int listmenu);
int mmiScreenAddText(int slot, int type, char *value);
int mmiScreenFinish(int slot);
int mmiScreenError10(int slot);
void mmiSessionDestroyed(int slot);
#endif
};
Expand Down
10 changes: 2 additions & 8 deletions lib/python/Screens/Ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def InitCiConfig():
config.ci[slot].use_static_pin = ConfigYesNo(default=True)
config.ci[slot].static_pin = ConfigPIN(default=0)
config.ci[slot].show_ci_messages = ConfigYesNo(default=True)
config.ci[slot].supress_error10_message = ConfigYesNo(default=False)
config.ci[slot].disable_operator_profile = ConfigYesNo(default=False)
if BoxInfo.getItem("CI%dSupportsHighBitrates" % slot):
highBitrateChoices = [("normal", _("normal")), ("high", _("high"))]
if exists("/proc/stb/tsmux/ci%d_tsclk_choices" % slot):
Expand Down Expand Up @@ -331,7 +331,6 @@ def __init__(self):
self.auto_close = False
self.ci = {}
self.dlgs = {}
self.err10supressed = False
eDVBCI_UI.getInstance().ciStateChanged.get().append(self.ciStateChanged)

def setSession(self, session):
Expand All @@ -350,11 +349,6 @@ def ciStateChanged(self, slot):
if config.ci[slot].show_ci_messages.value:
show_ui = True
screen_data = handler.getMMIScreen(slot)
if handler.isError10(slot) and config.ci[slot].supress_error10_message.value:
if not self.err10supressed:
self.err10supressed = True
handler.answerMenu(slot, 0)
show_ui = False
if config.ci[slot].use_static_pin.value:
if screen_data is not None and len(screen_data):
ci_tag = screen_data[0][0]
Expand Down Expand Up @@ -475,7 +469,7 @@ def appendEntries(self, slot, state):
self.list.append((_("Enter persistent PIN code"), ConfigNothing(), 5, slot))
self.list.append((_("Reset persistent PIN code"), ConfigNothing(), 6, slot))
self.list.append((_("Show CI messages"), config.ci[slot].show_ci_messages, 3, slot))
self.list.append((_("Hide and confirm invalid key message"), config.ci[slot].supress_error10_message, 3, slot))
self.list.append((_("Disable operator profiles"), config.ci[slot].disable_operator_profile, 3, slot))
self.list.append((_("Multiple service support"), config.ci[slot].canDescrambleMultipleServices, 3, slot))
if BoxInfo.getItem("CI%dSupportsHighBitrates" % slot):
self.list.append((_("High bitrate support"), config.ci[slot].highBitrate, 3, slot))
Expand Down

0 comments on commit 0f4e056

Please sign in to comment.