Browse Source

notify: Add no_code_word/code_word_ok events.

Georgi Chorbadzhiyski 12 years ago
parent
commit
2a484e783b
3 changed files with 13 additions and 3 deletions
  1. 1
    0
      ChangeLog
  2. 8
    2
      camd.c
  3. 4
    1
      tsdecrypt.c

+ 1
- 0
ChangeLog View File

@@ -1,4 +1,5 @@
1 1
 xxxx-xx-xx : Version -next
2
+ * notify: Added no_code_word/code_word_ok events.
2 3
  * notify: Added input_timeout/input_ok events.
3 4
  * notify: Added start/stop events.
4 5
  * notify: Added option to execute external script on event.

+ 8
- 2
camd.c View File

@@ -34,6 +34,7 @@
34 34
 #include "data.h"
35 35
 #include "util.h"
36 36
 #include "camd.h"
37
+#include "notify.h"
37 38
 
38 39
 static int connect_to(struct in_addr ip, int port) {
39 40
 	ts_LOGf("CAM | Connecting to server %s:%d\n", inet_ntoa(ip), port);
@@ -164,7 +165,8 @@ READ:
164 165
 
165 166
 	int valid_cw = memcmp(c->key->cw, invalid_cw, 16) != 0;
166 167
 	if (!c->key->is_valid_cw && valid_cw) {
167
-		ts_LOGf("CW  | OK: Valid CW was received.\n");
168
+		ts_LOGf("CW  | OK: Valid code word was received.\n");
169
+		notify(ts, "CODE_WORD_OK", "Valid code word was received.");
168 170
 	}
169 171
 	c->key->is_valid_cw = valid_cw;
170 172
 
@@ -255,8 +257,12 @@ static int camd35_send_ecm(struct ts *ts, uint16_t ca_id, uint16_t service_id, u
255 257
 	ret = camd35_recv_cw(ts);
256 258
 	if (ret < 48) {
257 259
 		ts->is_cw_error = 1;
258
-		if (ts->key.ts && time(NULL) - ts->key.ts > KEY_VALID_TIME)
260
+		if (ts->key.ts && time(NULL) - ts->key.ts > KEY_VALID_TIME) {
261
+			if (c->key->is_valid_cw)
262
+				notify(ts, "NO_CODE_WORD", "No code word was set in %ld sec. Decryption is disabled.",
263
+					time(NULL) - ts->key.ts);
259 264
 			c->key->is_valid_cw = 0;
265
+		}
260 266
 		return 0;
261 267
 	}
262 268
 

+ 4
- 1
tsdecrypt.c View File

@@ -468,7 +468,10 @@ static void report_ecms(struct ts *ts, time_t now) {
468 468
 }
469 469
 
470 470
 static void report_cw_warn(struct ts *ts, time_t now) {
471
-	ts_LOGf("CW  | *** No valid CW was received for %lu seconds!\n", now - ts->cw_last_warn);
471
+	notify(ts, "NO_CODE_WORD", "No valid code word was received for %ld sec.",
472
+		now - ts->cw_last_warn);
473
+	ts_LOGf("CW  | *ERR* No valid code word was received for %ld seconds!\n",
474
+		now - ts->cw_last_warn);
472 475
 	ts->cw_last_warn = now;
473 476
 }
474 477
 

Loading…
Cancel
Save