]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Announce the connection status of a server to the webui
authorsb1066 <sb1066@gmail.com>
Sun, 25 Oct 2009 12:26:17 +0000 (12:26 +0000)
committersb1066 <sb1066@gmail.com>
Sun, 25 Oct 2009 12:26:17 +0000 (12:26 +0000)
src/cwc.c

index d6fbc0cd5a04970edcbea3b6b3a54f14bf8724bf..eb3052adbc02f0e5afb926e13712130651a47cb5 100644 (file)
--- a/src/cwc.c
+++ b/src/cwc.c
@@ -141,6 +141,7 @@ typedef struct cwc_transport {
  */
 typedef struct cwc {
   int cwc_fd;
+  int cwc_connected;
 
   int cwc_retry_delay;
 
@@ -420,6 +421,13 @@ cwc_send_ka(cwc_t *cwc)
   cwc_send_msg(cwc, buf, 3, 0);
 }
 
+static void cwc_comet_status_update(cwc_t *cwc){
+  htsmsg_t *m = htsmsg_create_map();
+
+  htsmsg_add_str(m, "id", cwc->cwc_id);
+  htsmsg_add_u32(m, "connected", !!cwc->cwc_connected);
+  notify_by_msg("cwcStatus", m);
+}
 
 /**
  * Handle reply to card data request
@@ -454,6 +462,8 @@ cwc_decode_card_data_reply(cwc_t *cwc, uint8_t *msg, int len)
     return -1;
   }
 
+  cwc->cwc_connected = 1;
+  cwc_comet_status_update(cwc);
   cwc->cwc_caid = (msg[4] << 8) | msg[5];
   n = psi_caid2name(cwc->cwc_caid) ?: "Unknown";
 
@@ -814,7 +824,8 @@ cwc_thread(void *aux)
       cwc->cwc_fd = -1;
       close(fd);
       cwc->cwc_caid = 0;
-      
+      cwc->cwc_connected = 0;
+      cwc_comet_status_update(cwc);
       tvhlog(LOG_INFO, "cwc", "Disconnected from %s",  cwc->cwc_hostname);
     }
 
@@ -1114,6 +1125,7 @@ cwc_record_build(cwc_t *cwc)
 
   htsmsg_add_str(e, "id", cwc->cwc_id);
   htsmsg_add_u32(e, "enabled",  !!cwc->cwc_enabled);
+  htsmsg_add_u32(e, "connected", !!cwc->cwc_connected);
 
   htsmsg_add_str(e, "hostname", cwc->cwc_hostname ?: "");
   htsmsg_add_u32(e, "port", cwc->cwc_port);