]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix some updating issues related to cwcs
authorAndreas Öman <andreas@lonelycoder.com>
Sat, 17 May 2008 07:47:38 +0000 (07:47 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Sat, 17 May 2008 07:47:38 +0000 (07:47 +0000)
ajaxui/ajaxui_config_cwc.c
ajaxui/ajaxui_mailbox.c
ajaxui/ajaxui_mailbox.h
cwc.c
cwc.h
notify.c
notify.h

index 569f95752f9bb65baedcc256d886421ec03a579f..a386fee134952d1f590af370d9a35035bb36d9a0 100644 (file)
@@ -123,10 +123,9 @@ ajax_cwclist(http_connection_t *hc, http_reply_t *hr,
                                   "Username",
                                   "Enabled",
                                   "Status",
-                                  "Crypto",
                                   "",
                                    NULL}, 
-                (int[]){3, 2, 1, 6, 6, 1});
+                (int[]){3, 2, 1, 12, 1});
 
   TAILQ_FOREACH(cwc, &cwcs, cwc_link) {
     snprintf(id, sizeof(id), "cwc_%d", cwc->cwc_id);
@@ -142,12 +141,11 @@ ajax_cwclist(http_connection_t *hc, http_reply_t *hr,
                    "<input %stype=\"checkbox\" class=\"nicebox\" "
                    "onChange=\"new Ajax.Request('/ajax/cwcchange', "
                    "{parameters: {checked: this.checked, id: %d}})\">",
-                   1 ? "checked " : "", cwc->cwc_id);
+                   cwc->cwc_tcp_session.tcp_enabled
+                   ? "checked " : "", cwc->cwc_id);
 
     ajax_table_cell(&ta, "status", cwc_status_to_text(cwc));
 
-    ajax_table_cell(&ta, "crypto", cwc_crypto_to_text(cwc));
-
     ajax_table_cell(&ta, NULL,
                    "<a href=\"javascript:void(0)\" "
                    "onClick=\"dellistentry('/ajax/cwcdel', '%d', '%s')\">"
@@ -243,7 +241,7 @@ ajax_cwcchange(http_connection_t *hc, http_reply_t *hr,
   if((txt = http_arg_get(&hc->hc_req_args, "checked")) == NULL)
     return HTTP_STATUS_BAD_REQUEST;
 
-  //  cwc_set_state(cwc, atoi(txt));
+  cwc_set_enable(cwc, !strcmp(txt, "true"));
   http_output(hc, hr, "text/javascript; charset=UTF8", NULL, 0);
   return 0;
 }
index d41ada929299b3fd61b8557095ffa3c633c6eccc..067a9dc4969bda44a9230272392e702ce732924c 100644 (file)
@@ -498,14 +498,3 @@ ajax_mailbox_cwc_status_change(struct cwc *cwc)
 
   ajax_mailbox_update_div("cwc", "status", id, cwc_status_to_text(cwc));
 }
-
-
-
-void
-ajax_mailbox_cwc_crypto_change(struct cwc *cwc)
-{
-  char id[20];
-  snprintf(id, sizeof(id), "cwc_%d", cwc->cwc_id);
-
-  ajax_mailbox_update_div("cwc", "crypto", id, cwc_crypto_to_text(cwc));
-}
index ee5983c486737e98bda08c6420b87eb818678201..b9d7d587575bcc3558023028e4b2e7bcea8f3efe 100644 (file)
@@ -45,6 +45,4 @@ void ajax_mailbox_transport_status_change(struct th_transport *t);
 struct cwc;
 void ajax_mailbox_cwc_status_change(struct cwc *cwc);
 
-void ajax_mailbox_cwc_crypto_change(struct cwc *cwc);
-
 #endif /* AJAXUI_MAILBOX_H_ */
diff --git a/cwc.c b/cwc.c
index 8018f8fe000ef9939097fff00f84de1184ce89ab..caebf869ffe2c330bf9689f85677ea948cb77307 100644 (file)
--- a/cwc.c
+++ b/cwc.c
@@ -386,8 +386,6 @@ cwc_dispatch_card_data_reply(cwc_t *cwc, uint8_t msgtype,
   cwc->cwc_caid = (msg[4] << 8) | msg[5];
   n = psi_caid2name(cwc->cwc_caid) ?: "Unknown";
 
-  notify_cwc_crypto_change(cwc);
-
   syslog(LOG_INFO, "cwc: %s: Connected as user 0x%02x "
         "to a %s-card [0x%04x : %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x] "
         "with %d providers", 
@@ -814,7 +812,7 @@ cwc_save(void)
            cwc->cwc_confedkey[0xb],
            cwc->cwc_confedkey[0xc],
            cwc->cwc_confedkey[0xd]);
-    fprintf(fp, "\tenabled = %d\n", 1);
+    fprintf(fp, "\tenabled = %d\n", cwc->cwc_tcp_session.tcp_enabled);
 
 
     fprintf(fp, "}\n");
@@ -894,9 +892,7 @@ cwc_add(const char *hostname, const char *porttxt, const char *username,
     return "Enabled not set";
 
   cwc = tcp_create_client(hostname, port, sizeof(cwc_t), 
-                         "cwc", cwc_tcp_callback);
-
-  //  cwc->cwc_enabled = atoi(enabled);
+                         "cwc", cwc_tcp_callback, atoi(enabled));
   cwc->cwc_username = strdup(username);
 
   if(salt) {
@@ -948,23 +944,15 @@ cwc_delete(cwc_t *cwc)
   cwc_save();
 }
 
-#if 0
 /**
  *
  */
 void
 cwc_set_enable(cwc_t *cwc, int enabled)
 {
-  if(cwc->enabled == enabled)
-    return;
-
-  cwc->enabled = enabled;
-
-  tcp_client_set_state(&cwc->cwc_tcp_session, enabled);
+  tcp_enable_disable(&cwc->cwc_tcp_session, enabled);
   cwc_save();
 }
-#endif
-
 
 
 /**
@@ -1011,25 +999,24 @@ static struct strtab cwcstatustab[] = {
 const char *
 cwc_status_to_text(struct cwc *cwc)
 {
+  static char buf[100];
+  char buf2[30];
+  const char *n;
+
   if(cwc->cwc_state == CWC_STATE_IDLE)
     return cwc->cwc_errtxt ?: "Not connected";
 
-  return val2str(cwc->cwc_state, cwcstatustab) ?: "Invalid status";
-}
-
-const char *
-cwc_crypto_to_text(struct cwc *cwc)
-{
-  const char *n;
-  static char buf[40];
+  if(cwc->cwc_state == CWC_STATE_RUNNING) {
 
-  if(cwc->cwc_state != CWC_STATE_RUNNING)
-    return "Unknown";
+    n = psi_caid2name(cwc->cwc_caid);
+    if(n == NULL) {
+      snprintf(buf2, sizeof(buf2), "0x%x", cwc->cwc_caid);
+      n = buf2;
+    }
 
-  n = psi_caid2name(cwc->cwc_caid);
-  if(n != NULL)
-    return n;
+    snprintf(buf, sizeof(buf), "Connected to a %s card", n);
+    return buf;
+  }
 
-  snprintf(buf, sizeof(buf), "0x%x", cwc->cwc_caid);
-  return buf;
+  return val2str(cwc->cwc_state, cwcstatustab) ?: "Invalid status";
 }
diff --git a/cwc.h b/cwc.h
index 202ed34c23a4210109a46d4f60f0d2052f63bd01..9da32422551912827681724defd5342877a3469f 100644 (file)
--- a/cwc.h
+++ b/cwc.h
@@ -85,6 +85,4 @@ void cwc_delete(cwc_t *cwc);
 
 void cwc_set_enable(cwc_t *cwc, int enabled);
 
-const char *cwc_crypto_to_text(struct cwc *cwc);
-
 #endif /* CWC_H_ */
index 484567d6b0ac45967ee9691dfeba71a32ca50201..879ed7c9fb5f33cb5cd47c54e871b4ea72135a32 100644 (file)
--- a/notify.c
+++ b/notify.c
@@ -92,9 +92,3 @@ notify_cwc_status_change(struct cwc *cwc)
 {
   ajax_mailbox_cwc_status_change(cwc);
 }
-
-void
-notify_cwc_crypto_change(struct cwc *cwc)
-{
-  ajax_mailbox_cwc_status_change(cwc);
-}
index 82c63f2f21b68d63f76f564805fb970da659e911..a97ef1e845d2fb044f0900754431252f83252f4c 100644 (file)
--- a/notify.h
+++ b/notify.h
@@ -43,6 +43,4 @@ void notify_transprot_status_change(struct th_transport *t);
 struct cwc;
 void notify_cwc_status_change(struct cwc *cwc);
 
-void notify_cwc_crypto_change(struct cwc *cwc);
-
 #endif /* NOTIFY_H_ */