From: Damjan Marion Date: Sat, 2 May 2015 21:46:35 +0000 (+0200) Subject: linuxdvb_ca: CAM PIN handling trough GUI X-Git-Tag: v4.1~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5bb7300324d1ac8461c640682d90aa3b059c966;p=thirdparty%2Ftvheadend.git linuxdvb_ca: CAM PIN handling trough GUI --- diff --git a/src/input/mpegts/linuxdvb/linuxdvb_ca.c b/src/input/mpegts/linuxdvb/linuxdvb_ca.c index 150f638b3..3d0d6517c 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_ca.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_ca.c @@ -119,6 +119,29 @@ const idclass_t linuxdvb_ca_class = .off = offsetof(linuxdvb_ca_t, lca_enabled), .notify = linuxdvb_ca_class_enabled_notify, }, + { + .type = PT_BOOL, + .id = "pin_reply", + .name = "Reply to CAM PIN Enquiries", + .off = offsetof(linuxdvb_ca_t, lca_pin_reply), + .opts = PO_ADVANCED, + }, + { + .type = PT_STR, + .id = "pin", + .name = "PIN", + .off = offsetof(linuxdvb_ca_t, lca_pin_str), + .opts = PO_ADVANCED | PO_PASSWORD, + .def.s = "1234", + }, + { + .type = PT_STR, + .id = "pin_match", + .name = "PIN Enquiry Match String", + .off = offsetof(linuxdvb_ca_t, lca_pin_match_str), + .opts = PO_ADVANCED, + .def.s = "PIN", + }, { .type = PT_STR, .id = "ca_path", @@ -391,18 +414,25 @@ linuxdvb_ca_mmi_enq_cb(void *arg, uint8_t slot_id, uint16_t session_num, uint8_t *text, uint32_t text_size) { linuxdvb_ca_t * lca = arg; + char buffer[256]; - tvhlog(LOG_NOTICE, "en50221", "MMI enquiry from CAM in slot %u: %.*s (%s%u digits)", - slot_id, text_size, text,blind_answ ? "blind " : "" , exp_answ_len); + snprintf(buffer, sizeof(buffer), "%.*s", text_size, text); - /* cancel dialog */ - en50221_app_mmi_answ(lca->lca_mmi_resource, session_num, MMI_ANSW_ID_CANCEL, NULL, 0); + tvhlog(LOG_NOTICE, "en50221", "MMI enquiry from CAM in slot %u: %s (%s%u digits)", + slot_id, buffer, blind_answ ? "blind " : "" , exp_answ_len); - /* TODO add gui to enter PIN - keeping this disabled as - entering wrong pin can block card */ + if (lca->lca_pin_reply && + (strlen((char *) lca->lca_pin_str) == exp_answ_len) && + strstr((char *) buffer, lca->lca_pin_match_str)) + { + tvhtrace("en50221", "answering to PIN enquiry"); + en50221_app_mmi_answ(lca->lca_mmi_resource, session_num, + MMI_ANSW_ID_ANSWER, (uint8_t *) lca->lca_pin_str, + exp_answ_len); + } - //uint8_t answ[4] = "1234"; - //en50221_app_mmi_answ(lca->lca_mmi_resource, session_num, MMI_ANSW_ID_ANSWER, answ, 4); + en50221_app_mmi_close(lca->lca_mmi_resource, session_num, + MMI_CLOSE_MMI_CMD_ID_IMMEDIATE, 0); return 0; } @@ -428,8 +458,8 @@ linuxdvb_ca_mmi_menu_cb(void *arg, uint8_t slot_id, uint16_t session_num, tvhlog(LOG_NOTICE, "en50221", " bottom: %.*s", bottom->text_length, bottom->text); /* cancel menu */ - en50221_app_mmi_menu_answ(lca->lca_mmi_resource, session_num, 0); - + en50221_app_mmi_close(lca->lca_mmi_resource, session_num, + MMI_CLOSE_MMI_CMD_ID_IMMEDIATE, 0); return 0; } @@ -454,8 +484,8 @@ linuxdvb_ca_app_mmi_list_cb(void *arg, uint8_t slot_id, uint16_t session_num, tvhlog(LOG_NOTICE, "en50221", " bottom: %.*s", bottom->text_length, bottom->text); /* cancel menu */ - en50221_app_mmi_menu_answ(lca->lca_mmi_resource, session_num, 0); - + en50221_app_mmi_close(lca->lca_mmi_resource, session_num, + MMI_CLOSE_MMI_CMD_ID_IMMEDIATE, 0); return 0; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_private.h b/src/input/mpegts/linuxdvb/linuxdvb_private.h index b3f2c49a9..14ff454dd 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_private.h +++ b/src/input/mpegts/linuxdvb/linuxdvb_private.h @@ -201,6 +201,9 @@ struct linuxdvb_ca * CAM module info */ char lca_cam_menu_string[64]; + int lca_pin_reply; + char *lca_pin_str; + char *lca_pin_match_str; }; #endif