From 29037b3941fe72a5fcdf862f32244dcabdfbd6a6 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Thu, 24 Sep 2015 12:32:28 +0300 Subject: [PATCH] gui/cam_menu.cpp: hack: save blind answer as pincode and re-use it if enabled Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/04aa958d1923e2f540a5039d4a01669b6fd74073 Author: [CST] Focus Date: 2015-09-24 (Thu, 24 Sep 2015) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/locale/english.locale | 1 + src/gui/cam_menu.cpp | 34 ++++++++++++++++++++++++++++++---- src/neutrino.cpp | 4 ++++ src/system/locals.h | 1 + src/system/locals_intern.h | 1 + src/system/settings.h | 2 ++ 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/data/locale/english.locale b/data/locale/english.locale index ff8e5a356..8e0c8c946 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -278,6 +278,7 @@ ci.inserted CAM inserted in slot ci.removed CAM removed from slot ci.reset Reset ci.reset_standby Reset after standby +ci.save_pincode Save pincode ci.settings Conditional access ci.timeout Timeout waiting CI menu ready ci.waiting Waiting for CI answer diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index 83a7bfa38..7247db7be 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -52,6 +52,7 @@ #include #include #include +#include void CCAMMenuHandler::init(void) { @@ -114,6 +115,7 @@ int CCAMMenuHandler::doMainMenu() cammenu->addItem( new CMenuOptionNumberChooser(LOCALE_CI_CLOCK, &g_settings.ci_clock, true, 6, 12, this)); } cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_IGNORE_MSG, &g_settings.ci_ignore_messages, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true)); + cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_SAVE_PINCODE, &g_settings.ci_save_pincode, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this)); cammenu->addItem( GenericMenuSeparatorLine ); } @@ -393,9 +395,26 @@ int CCAMMenuHandler::handleCamMsg(const neutrino_msg_t msg, neutrino_msg_data_t std::string ENQAnswer; - CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); - Inquiry->exec(NULL, ""); - delete Inquiry; + if (/* !from_menu && */ g_settings.ci_save_pincode && pMmiEnquiry->blind != 0 && (int) g_settings.ci_pincode.length() == pMmiEnquiry->answerlen) { + static int acount = 0; + static time_t last_ask = 0; + + ENQAnswer = g_settings.ci_pincode; + printf("CCAMMenuHandler::handleCamMsg: using saved answer [%s] (#%d, time diff %d)\n", ENQAnswer.c_str(), acount, (int) (time_monotonic() - last_ask)); + if ((time_monotonic() - last_ask) < 10) { + acount++; + if (acount > 4) + g_settings.ci_pincode.clear(); + } else { + last_ask = time_monotonic(); + acount = 0; + } + } else { + CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); + Inquiry->exec(NULL, ""); + delete Inquiry; + g_settings.ci_pincode = ENQAnswer; + } printf("CCAMMenuHandler::handleCamMsg: input=[%s]\n", ENQAnswer.c_str()); @@ -504,12 +523,19 @@ int CCAMMenuHandler::doMenu(int slot, CA_SLOT_TYPE slotType) return res; } -bool CCAMMenuHandler::changeNotify(const neutrino_locale_t OptionName, void * /*Data*/) +bool CCAMMenuHandler::changeNotify(const neutrino_locale_t OptionName, void * Data) { if (ARE_LOCALES_EQUAL(OptionName, LOCALE_CI_CLOCK)) { printf("CCAMMenuHandler::changeNotify: ci_clock %d\n", g_settings.ci_clock); ca->SetTSClock(g_settings.ci_clock * 1000000); return true; } + else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_CI_SAVE_PINCODE)) { + int enabled = *(int *) Data; + if (!enabled) { + printf("CCAMMenuHandler::changeNotify: clear saved pincode\n"); + g_settings.ci_pincode.clear(); + } + } return false; } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 3da99f479..ef3a2c0c3 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -416,6 +416,8 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.ci_standby_reset = configfile.getInt32("ci_standby_reset", 0); g_settings.ci_clock = configfile.getInt32("ci_clock", 9); g_settings.ci_ignore_messages = configfile.getInt32("ci_ignore_messages", 0); + g_settings.ci_save_pincode = configfile.getInt32("ci_save_pincode", 0); + g_settings.ci_pincode = configfile.getString("ci_pincode", ""); #ifndef CPU_FREQ g_settings.cpufreq = 0; @@ -967,6 +969,8 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("ci_standby_reset", g_settings.ci_standby_reset); configfile.setInt32("ci_clock", g_settings.ci_clock); configfile.setInt32("ci_ignore_messages", g_settings.ci_ignore_messages); + configfile.setInt32("ci_save_pincode", g_settings.ci_save_pincode); + configfile.setString("ci_pincode", g_settings.ci_pincode); configfile.setInt32( "make_hd_list", g_settings.make_hd_list); configfile.setInt32( "make_webtv_list", g_settings.make_webtv_list); diff --git a/src/system/locals.h b/src/system/locals.h index 2a2451753..95cd72516 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -305,6 +305,7 @@ typedef enum LOCALE_CI_REMOVED, LOCALE_CI_RESET, LOCALE_CI_RESET_STANDBY, + LOCALE_CI_SAVE_PINCODE, LOCALE_CI_SETTINGS, LOCALE_CI_TIMEOUT, LOCALE_CI_WAITING, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 72728f9ac..bfd9e78b2 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -305,6 +305,7 @@ const char * locale_real_names[] = "ci.removed", "ci.reset", "ci.reset_standby", + "ci.save_pincode", "ci.settings", "ci.timeout", "ci.waiting", diff --git a/src/system/settings.h b/src/system/settings.h index f955e4433..97b33ba1c 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -222,6 +222,8 @@ struct SNeutrinoSettings int ci_standby_reset; int ci_clock; int ci_ignore_messages; + int ci_save_pincode; + std::string ci_pincode; int radiotext_enable; int easymenu;