]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
linuxdvb_ca: CAM PIN handling trough GUI
authorDamjan Marion <damarion@cisco.com>
Sat, 2 May 2015 21:46:35 +0000 (23:46 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 4 May 2015 07:11:55 +0000 (09:11 +0200)
src/input/mpegts/linuxdvb/linuxdvb_ca.c
src/input/mpegts/linuxdvb/linuxdvb_private.h

index 150f638b31129ec2ef5e459b395aa0b3c645528d..3d0d6517cd3b92b7f1cec7614083db347225c053 100644 (file)
@@ -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;
 }
 
index b3f2c49a9c915a2d7206cdd13458b5505999ff17..14ff454dd7caad089517a15bff117e5056b004f3 100644 (file)
@@ -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