diff --git a/ajaxui/ajaxui_config_cwc.c b/ajaxui/ajaxui_config_cwc.c
index 569f9575..a386fee1 100644
--- a/ajaxui/ajaxui_config_cwc.c
+++ b/ajaxui/ajaxui_config_cwc.c
@@ -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,
"",
- 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,
""
@@ -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;
}
diff --git a/ajaxui/ajaxui_mailbox.c b/ajaxui/ajaxui_mailbox.c
index d41ada92..067a9dc4 100644
--- a/ajaxui/ajaxui_mailbox.c
+++ b/ajaxui/ajaxui_mailbox.c
@@ -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));
-}
diff --git a/ajaxui/ajaxui_mailbox.h b/ajaxui/ajaxui_mailbox.h
index ee5983c4..b9d7d587 100644
--- a/ajaxui/ajaxui_mailbox.h
+++ b/ajaxui/ajaxui_mailbox.h
@@ -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 8018f8fe..caebf869 100644
--- 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";
+ if(cwc->cwc_state == CWC_STATE_RUNNING) {
+
+ n = psi_caid2name(cwc->cwc_caid);
+ if(n == NULL) {
+ snprintf(buf2, sizeof(buf2), "0x%x", cwc->cwc_caid);
+ n = buf2;
+ }
+
+ snprintf(buf, sizeof(buf), "Connected to a %s card", n);
+ return buf;
+ }
+
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)
- return "Unknown";
-
- n = psi_caid2name(cwc->cwc_caid);
- if(n != NULL)
- return n;
-
- snprintf(buf, sizeof(buf), "0x%x", cwc->cwc_caid);
- return buf;
-}
diff --git a/cwc.h b/cwc.h
index 202ed34c..9da32422 100644
--- 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_ */
diff --git a/notify.c b/notify.c
index 484567d6..879ed7c9 100644
--- 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);
-}
diff --git a/notify.h b/notify.h
index 82c63f2f..a97ef1e8 100644
--- 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_ */