fix olsrd build
[openwrt.git] / package / kismet / patches / 120-remove_sound.patch
1 diff -urN kismet-2005-04-R1.old/Makefile.in kismet-2005-04-R1.dev/Makefile.in
2 --- kismet-2005-04-R1.old/Makefile.in 2005-05-04 21:09:18.000000000 +0200
3 +++ kismet-2005-04-R1.dev/Makefile.in 2005-05-04 21:19:26.000000000 +0200
4 @@ -39,7 +39,7 @@
5 DEPEND = .depend
6
7 # Objects
8 -PSO = util.o ringbuf.o configfile.o speech.o ifcontrol.o iwcontrol.o packet.o \
9 +PSO = util.o ringbuf.o configfile.o ifcontrol.o iwcontrol.o packet.o \
10 pcapsource.o wtapfilesource.o \
11 dronesource.o packetsourcetracker.o kis_packsources.o \
12 wtapdump.o wtaplocaldump.o gpsdump.o airsnortdump.o fifodump.o \
13 @@ -55,7 +55,7 @@
14 timetracker.o gpsd.o server_globals.o kismet_drone.o
15 DRONE = kismet_drone
16
17 -NCO = util.o configfile.o speech.o manuf.o tcpclient.o \
18 +NCO = util.o configfile.o manuf.o tcpclient.o \
19 frontend.o cursesfront.o \
20 panelfront.o panelfront_display.o panelfront_input.o \
21 gpsd.o getopt.o kismet_client.o
22 diff -urN kismet-2005-04-R1.old/kismet_client.cc kismet-2005-04-R1.dev/kismet_client.cc
23 --- kismet-2005-04-R1.old/kismet_client.cc 2005-04-03 07:33:42.000000000 +0200
24 +++ kismet-2005-04-R1.dev/kismet_client.cc 2005-05-04 21:23:14.000000000 +0200
25 @@ -28,7 +28,6 @@
26 #include "cursesfront.h"
27 #include "panelfront.h"
28 #include "configfile.h"
29 -#include "speech.h"
30
31 #ifndef exec_name
32 char *exec_name;
33 @@ -47,10 +46,6 @@
34 char *configfile;
35 char *uiconfigfile;
36 char *server = NULL;
37 -int sound = -1;
38 -int speech = -1;
39 -int speech_encoding = 0;
40 -string speech_sentence_encrypted, speech_sentence_unencrypted;
41 unsigned int metric = 0;
42 unsigned int reconnect = 0;
43
44 @@ -58,20 +53,9 @@
45 string configdir, groupfile;
46 FILE *group_file = NULL;
47
48 -// Pipe file descriptor pairs and fd's
49 -int soundpair[2];
50 -int speechpair[2];
51 -pid_t soundpid = -1, speechpid = -1;
52 -
53 // Catch our interrupt
54 void CatchShutdown(int sig) {
55
56 - // Kill our sound players
57 - if (soundpid > 0)
58 - kill(soundpid, 9);
59 - if (speechpid > 0)
60 - kill(speechpid, 9);
61 -
62 if (group_track) {
63 if ((group_file = fopen(groupfile.c_str(), "w")) == NULL) {
64 fprintf(stderr, "WARNING: Unable to open '%s' for writing, groups will not be saved.\n",
65 @@ -115,215 +99,6 @@
66 exit(0);
67 }
68
69 -// Subprocess sound handler
70 -void SoundHandler(int *fds, const char *player, map<string, string> soundmap) {
71 - int read_sock = fds[0];
72 -
73 - close(fds[1]);
74 -
75 - signal(SIGPIPE, PipeHandler);
76 -
77 - fd_set rset;
78 -
79 - char data[1024];
80 -
81 - pid_t sndpid = -1;
82 - int harvested = 1;
83 -
84 - while (1) {
85 - FD_ZERO(&rset);
86 - FD_SET(read_sock, &rset);
87 - char *end;
88 -
89 - memset(data, 0, 1024);
90 -
91 - if (harvested == 0) {
92 - // We consider a wait error to be a sign that the child pid died
93 - // so we flag it as harvested and keep on going
94 - pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
95 - if (harvestpid == -1 || harvestpid == sndpid)
96 - harvested = 1;
97 - }
98 -
99 - struct timeval tim;
100 - tim.tv_sec = 1;
101 - tim.tv_usec = 0;
102 -
103 - if (select(read_sock + 1, &rset, NULL, NULL, &tim) < 0) {
104 - if (errno != EINTR) {
105 - exit(1);
106 - }
107 - }
108 -
109 - if (FD_ISSET(read_sock, &rset)) {
110 - int ret;
111 - ret = read(read_sock, data, 1024);
112 -
113 - // We'll die off if we get a read error, and we'll let kismet on the
114 - // other side detact that it died
115 - if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
116 - exit(1);
117 -
118 - if ((end = strstr(data, "\n")) == NULL)
119 - continue;
120 -
121 - end[0] = '\0';
122 - }
123 -
124 - if (data[0] == '\0')
125 - continue;
126 -
127 - // If we've harvested the process, spawn a new one and watch it
128 - // instead. Otherwise, we just let go of the data we read
129 - if (harvested == 1) {
130 - // Only take the first line
131 - char *nl;
132 - if ((nl = strchr(data, '\n')) != NULL)
133 - *nl = '\0';
134 -
135 - char snd[1024];
136 -
137 - if (soundmap.size() == 0)
138 - snprintf(snd, 1024, "%s", data);
139 - if (soundmap.find(data) != soundmap.end())
140 - snprintf(snd, 1024, "%s", soundmap[data].c_str());
141 - else
142 - continue;
143 -
144 - char plr[1024];
145 - snprintf(plr, 1024, "%s", player);
146 -
147 - harvested = 0;
148 - if ((sndpid = fork()) == 0) {
149 - // Suppress errors
150 - int nulfd = open("/dev/null", O_RDWR);
151 - dup2(nulfd, 1);
152 - dup2(nulfd, 2);
153 -
154 - char * const echoarg[] = { plr, snd, NULL };
155 - execve(echoarg[0], echoarg, NULL);
156 - }
157 - }
158 -
159 - data[0] = '\0';
160 - }
161 -}
162 -
163 -// Subprocess speech handler
164 -void SpeechHandler(int *fds, const char *player) {
165 - int read_sock = fds[0];
166 - close(fds[1]);
167 -
168 - fd_set rset;
169 -
170 - char data[1024];
171 -
172 - pid_t sndpid = -1;
173 - int harvested = 1;
174 -
175 - while (1) {
176 - FD_ZERO(&rset);
177 - FD_SET(read_sock, &rset);
178 - //char *end;
179 -
180 - memset(data, 0, 1024);
181 -
182 - struct timeval tim;
183 - tim.tv_sec = 1;
184 - tim.tv_usec = 0;
185 -
186 - if (select(read_sock + 1, &rset, NULL, NULL, &tim) < 0) {
187 - if (errno != EINTR) {
188 - exit(1);
189 - }
190 - }
191 -
192 - if (harvested == 0) {
193 - // We consider a wait error to be a sign that the child pid died
194 - // so we flag it as harvested and keep on going
195 - pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
196 - if (harvestpid == -1 || harvestpid == sndpid)
197 - harvested = 1;
198 - }
199 -
200 - if (FD_ISSET(read_sock, &rset)) {
201 - int ret;
202 - ret = read(read_sock, data, 1024);
203 -
204 - // We'll die off if we get a read error, and we'll let kismet on the
205 - // other side detact that it died
206 - if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
207 - exit(1);
208 -
209 - data[ret] = '\0';
210 -
211 - }
212 -
213 - if (data[0] == '\0')
214 - continue;
215 -
216 - // If we've harvested the process, spawn a new one and watch it
217 - // instead. Otherwise, we just let go of the data we read
218 - if (harvested == 1) {
219 - harvested = 0;
220 - if ((sndpid = fork()) == 0) {
221 - // Only take the first line
222 - char *nl;
223 - if ((nl = strchr(data, '\n')) != NULL)
224 - *nl = '\0';
225 -
226 - // Make sure it's shell-clean
227 - MungeToShell(data, strlen(data));
228 - char spk_call[1024];
229 - snprintf(spk_call, 1024, "echo \"(SayText \\\"%s\\\")\" | %s >/dev/null 2>/dev/null",
230 - data, player);
231 -
232 - system(spk_call);
233 -
234 - exit(0);
235 - }
236 - }
237 -
238 - data[0] = '\0';
239 - }
240 -}
241 -
242 -
243 -int PlaySound(string in_sound) {
244 -
245 - char snd[1024];
246 -
247 - snprintf(snd, 1024, "%s\n", in_sound.c_str());
248 -
249 - if (write(soundpair[1], snd, strlen(snd)) < 0) {
250 - char status[STATUS_MAX];
251 - snprintf(status, STATUS_MAX,
252 - "ERROR: Could not write to sound pipe. Stopping sound.");
253 - gui->WriteStatus(status);
254 -
255 - return 0;
256 - }
257 -
258 - return 1;
259 -}
260 -
261 -int SayText(string in_text) {
262 - char snd[1024];
263 -
264 - snprintf(snd, 1024, "%s\n", in_text.c_str());
265 -
266 - if (write(speechpair[1], snd, strlen(snd)) < 0) {
267 - char status[STATUS_MAX];
268 - snprintf(status, STATUS_MAX,
269 - "ERROR: Could not write to speech pipe. Stopping speech.");
270 - gui->WriteStatus(status);
271 -
272 - return 0;
273 - }
274 -
275 - return 1;
276 -}
277 -
278 int main(int argc, char *argv[]) {
279 exec_name = argv[0];
280
281 @@ -332,9 +107,6 @@
282
283 char *reqgui = NULL;
284
285 - string sndplay;
286 - const char *festival = NULL;
287 -
288 char *columns = NULL;
289 char *clientcolumns = NULL;
290
291 @@ -389,7 +161,6 @@
292 fprintf(stderr, "Using alternate UI config file: %s\n", uiconfigfile);
293 break;
294 case 'q':
295 - sound = 0;
296 break;
297 case 'g':
298 reqgui = strdup(optarg);
299 @@ -513,67 +284,6 @@
300 server = strdup(gui_conf->FetchOpt("host").c_str());
301 }
302
303 - if (gui_conf->FetchOpt("sound") == "true" && sound == -1) {
304 - if (gui_conf->FetchOpt("soundplay") != "") {
305 - sndplay = gui_conf->FetchOpt("soundplay");
306 - sound = 1;
307 -
308 - if (gui_conf->FetchOpt("soundopts") != "")
309 - sndplay += " " + gui_conf->FetchOpt("soundopts");
310 -
311 - if (gui_conf->FetchOpt("sound_new") != "")
312 - wav_map["new"] = gui_conf->FetchOpt("sound_new");
313 - if (gui_conf->FetchOpt("sound_new_wep") != "")
314 - wav_map["new_wep"] = gui_conf->FetchOpt("sound_new_wep");
315 - if (gui_conf->FetchOpt("sound_traffic") != "")
316 - wav_map["traffic"] = gui_conf->FetchOpt("sound_traffic");
317 - if (gui_conf->FetchOpt("sound_junktraffic") != "")
318 - wav_map["junktraffic"] = gui_conf->FetchOpt("sound_junktraffic");
319 - if (gui_conf->FetchOpt("sound_gpslock") != "")
320 - wav_map["gpslock"] = gui_conf->FetchOpt("sound_gpslock");
321 - if (gui_conf->FetchOpt("sound_gpslost") != "")
322 - wav_map["gpslost"] = gui_conf->FetchOpt("sound_gpslost");
323 - if (gui_conf->FetchOpt("sound_alert") != "")
324 - wav_map["alert"] = gui_conf->FetchOpt("sound_alert");
325 -
326 - } else {
327 - fprintf(stderr, "ERROR: Sound alerts enabled but no sound playing binary specified.\n");
328 - sound = 0;
329 - }
330 - } else if (sound == -1)
331 - sound = 0;
332 -
333 - /* Added by Shaw Innes 17/2/02 */
334 - if (gui_conf->FetchOpt("speech") == "true" && speech == -1) {
335 - if (gui_conf->FetchOpt("festival") != "") {
336 - festival = strdup(gui_conf->FetchOpt("festival").c_str());
337 - speech = 1;
338 -
339 - string speechtype = gui_conf->FetchOpt("speech_type");
340 -
341 - if (!strcasecmp(speechtype.c_str(), "nato"))
342 - speech_encoding = SPEECH_ENCODING_NATO;
343 - else if (!strcasecmp(speechtype.c_str(), "spell"))
344 - speech_encoding = SPEECH_ENCODING_SPELL;
345 - else
346 - speech_encoding = SPEECH_ENCODING_NORMAL;
347 -
348 - // Make sure we have encrypted text lines
349 - if (gui_conf->FetchOpt("speech_encrypted") == "" || gui_conf->FetchOpt("speech_unencrypted") == "") {
350 - fprintf(stderr, "ERROR: Speech request but speech_encrypted or speech_unencrypted line missing.\n");
351 - speech = 0;
352 - }
353 -
354 - speech_sentence_encrypted = gui_conf->FetchOpt("speech_encrypted");
355 - speech_sentence_unencrypted = gui_conf->FetchOpt("speech_unencrypted");
356 -
357 - } else {
358 - fprintf(stderr, "ERROR: Speech alerts enabled but no path to festival has been specified.\n");
359 - speech = 0;
360 - }
361 - } else if (speech == -1)
362 - speech = 0;
363 -
364 if (gui_conf->FetchOpt("decay") != "") {
365 if (sscanf(gui_conf->FetchOpt("decay").c_str(), "%d", &decay) != 1) {
366 fprintf(stderr, "FATAL: Illegal config file value for decay.\n");
367 @@ -631,45 +341,6 @@
368 }
369 }
370
371 - // Fork and find the sound options
372 - if (sound) {
373 - if (pipe(soundpair) == -1) {
374 - fprintf(stderr, "WARNING: Unable to create pipe for audio. Disabling sound.\n");
375 - sound = 0;
376 - } else {
377 - soundpid = fork();
378 -
379 - if (soundpid < 0) {
380 - fprintf(stderr, "WARNING: Unable to fork for audio. Disabling sound.\n");
381 - sound = 0;
382 - } else if (soundpid == 0) {
383 - SoundHandler(soundpair, sndplay.c_str(), wav_map);
384 - exit(0);
385 - }
386 -
387 - close(soundpair[0]);
388 - }
389 - }
390 -
391 - if (speech) {
392 - if (pipe(speechpair) == -1) {
393 - fprintf(stderr, "WARNING: Unable to create pipe for speech. Disabling speech.\n");
394 - speech = 0;
395 - } else {
396 - speechpid = fork();
397 -
398 - if (speechpid < 0) {
399 - fprintf(stderr, "WARNING: Unable to fork for speech. Disabling speech.\n");
400 - speech = 0;
401 - } else if (speechpid == 0) {
402 - SpeechHandler(speechpair, festival);
403 - exit(0);
404 - }
405 -
406 - close(speechpair[0]);
407 - }
408 - }
409 -
410 if (kismet_serv.Connect(guiport, guihost) < 0) {
411 fprintf(stderr, "FATAL: Could not connect to %s:%d.\n", guihost, guiport);
412 CatchShutdown(-1);
413 @@ -793,8 +464,6 @@
414
415 int num_networks = 0, num_packets = 0, num_noise = 0, num_dropped = 0;
416
417 - time_t last_click = time(0);
418 -
419 fd_set read_set;
420 FD_ZERO(&read_set);
421
422 @@ -876,10 +545,6 @@
423 }
424
425 if (pollret != 0) {
426 - if (pollret == CLIENT_ALERT)
427 - if (sound == 1)
428 - sound = PlaySound("alert");
429 -
430 if (strlen(tcpcli->FetchStatus()) != 0) {
431 gui->WriteStatus(tcpcli->FetchStatus());
432 // gui->DrawDisplay();
433 @@ -888,12 +553,8 @@
434 // The GPS only gets updated for the primary client
435 if (tcpcli == primary_client) {
436 if (tcpcli->FetchMode() == 0 && gpsmode != 0) {
437 - if (sound == 1 && gpsmode != -1)
438 - sound = PlaySound("gpslost");
439 gpsmode = 0;
440 } else if (tcpcli->FetchMode() != 0 && gpsmode == 0) {
441 - if (sound == 1 && gpsmode != -1)
442 - sound = PlaySound("gpslock");
443 gpsmode = 1;
444 }
445 }
446 @@ -901,28 +562,6 @@
447 if (tcpcli->FetchDeltaNumNetworks() > 0) {
448 wireless_network *newnet = tcpcli->FetchLastNewNetwork();
449
450 - if (sound == 1 && newnet != lastspoken) {
451 - if (newnet->crypt_set &&
452 - wav_map.find("new_wep") != wav_map.end())
453 - sound = PlaySound("new_wep");
454 - else
455 - sound = PlaySound("new");
456 - }
457 -
458 - if (speech == 1 && newnet != lastspoken) {
459 - string text;
460 -
461 - if (newnet != NULL) {
462 - if (newnet->crypt_set)
463 - text = ExpandSpeechString(speech_sentence_encrypted, newnet, speech_encoding);
464 - else
465 - text = ExpandSpeechString(speech_sentence_unencrypted, newnet, speech_encoding);
466 -
467 - speech = SayText(text.c_str());
468 - }
469 - }
470 -
471 - lastspoken = newnet;
472 }
473
474 num_networks += tcpcli->FetchNumNetworks();
475 @@ -930,17 +569,6 @@
476 num_noise += tcpcli->FetchNumNoise();
477 num_dropped += tcpcli->FetchNumDropped();
478
479 - if (tcpcli->FetchDeltaNumPackets() != 0) {
480 - if (time(0) - last_click >= decay && sound == 1) {
481 - if (tcpcli->FetchDeltaNumPackets() > tcpcli->FetchDeltaNumDropped()) {
482 - sound = PlaySound("traffic");
483 - } else {
484 - sound = PlaySound("junktraffic");
485 - }
486 -
487 - last_click = time(0);
488 - }
489 - }
490 }
491 }
492 } else {
493 diff -urN kismet-2005-04-R1.old/kismet_server.cc kismet-2005-04-R1.dev/kismet_server.cc
494 --- kismet-2005-04-R1.old/kismet_server.cc 2005-05-04 21:09:18.000000000 +0200
495 +++ kismet-2005-04-R1.dev/kismet_server.cc 2005-05-04 21:23:01.000000000 +0200
496 @@ -56,7 +56,6 @@
497 #include "timetracker.h"
498 #include "alertracker.h"
499
500 -#include "speech.h"
501 #include "tcpserver.h"
502 #include "server_globals.h"
503 #include "kismet_server.h"
504 @@ -98,7 +97,6 @@
505
506 FifoDumpFile fifodump;
507 TcpServer ui_server;
508 -int sound = -1;
509 packet_info last_info;
510 int decay;
511 channel_power channel_graph[CHANNEL_MAX];
512 @@ -112,10 +110,8 @@
513 macmap<wep_key_info *> bssid_wep_map;
514
515 // Pipe file descriptor pairs and fd's
516 -int soundpair[2];
517 -int speechpair[2];
518 int chanpair[2];
519 -pid_t soundpid = -1, speechpid = -1, chanpid = -1;
520 +pid_t chanpid = -1;
521
522 // Past alerts
523 unsigned int max_alerts = 50;
524 @@ -177,16 +173,6 @@
525 int tcpport = -1;
526 int tcpmax;
527
528 -//const char *sndplay = NULL;
529 -string sndplay;
530 -
531 -const char *festival = NULL;
532 -int speech = -1;
533 -int speech_encoding = 0;
534 -string speech_sentence_encrypted, speech_sentence_unencrypted;
535 -
536 -map<string, string> wav_map;
537 -
538 int beacon_log = 1;
539 int phy_log = 1;
540 int mangle_log = 0;
541 @@ -349,12 +335,6 @@
542
543 #endif
544
545 - // Kill our sound players
546 - if (soundpid > 0)
547 - kill(soundpid, 9);
548 - if (speechpid > 0)
549 - kill(speechpid, 9);
550 -
551 // Shut down the packet sources
552 sourcetracker.CloseSources();
553
554 @@ -365,227 +345,10 @@
555 exit(0);
556 }
557
558 -// Subprocess sound handler
559 -void SoundHandler(int *fds, const char *player, map<string, string> soundmap) {
560 - int read_sock = fds[0];
561 - close(fds[1]);
562 -
563 - fd_set rset;
564 -
565 - char data[1024];
566 -
567 - pid_t sndpid = -1;
568 - int harvested = 1;
569 -
570 - while (1) {
571 - FD_ZERO(&rset);
572 - FD_SET(read_sock, &rset);
573 - char *end;
574 -
575 - memset(data, 0, 1024);
576 -
577 - struct timeval tm;
578 - tm.tv_sec = 1;
579 - tm.tv_usec = 0;
580 -
581 - if (select(read_sock + 1, &rset, NULL, NULL, &tm) < 0) {
582 - if (errno != EINTR) {
583 - exit(1);
584 - }
585 - }
586 -
587 - if (harvested == 0) {
588 - // We consider a wait error to be a sign that the child pid died
589 - // so we flag it as harvested and keep on going
590 - pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
591 - if (harvestpid == -1 || harvestpid == sndpid)
592 - harvested = 1;
593 - }
594 -
595 - if (FD_ISSET(read_sock, &rset)) {
596 - int ret;
597 - ret = read(read_sock, data, 1024);
598 -
599 - // We'll die off if we get a read error, and we'll let kismet on the
600 - // other side detact that it died
601 - if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
602 - exit(1);
603 -
604 - if ((end = strstr(data, "\n")) == NULL)
605 - continue;
606 -
607 - end[0] = '\0';
608 - }
609 -
610 - if (data[0] == '\0')
611 - continue;
612 -
613 -
614 - // If we've harvested the process, spawn a new one and watch it
615 - // instead. Otherwise, we just let go of the data we read
616 - if (harvested == 1) {
617 - // Only take the first line
618 - char *nl;
619 - if ((nl = strchr(data, '\n')) != NULL)
620 - *nl = '\0';
621 -
622 - // Make sure it's shell-clean
623 -
624 - char snd[1024];
625 -
626 - if (soundmap.size() == 0)
627 - snprintf(snd, 1024, "%s", data);
628 - if (soundmap.find(data) != soundmap.end())
629 - snprintf(snd, 1024, "%s", soundmap[data].c_str());
630 - else
631 - continue;
632 -
633 - char plr[1024];
634 - snprintf(plr, 1024, "%s", player);
635 -
636 - harvested = 0;
637 - if ((sndpid = fork()) == 0) {
638 - // Suppress errors
639 - if (silent) {
640 - int nulfd = open("/dev/null", O_RDWR);
641 - dup2(nulfd, 1);
642 - dup2(nulfd, 2);
643 - }
644 -
645 - char * const echoarg[] = { plr, snd, NULL };
646 - execve(echoarg[0], echoarg, NULL);
647 - }
648 - }
649 - data[0] = '\0';
650 - }
651 -}
652 -
653 -// Subprocess speech handler
654 -void SpeechHandler(int *fds, const char *player) {
655 - int read_sock = fds[0];
656 - close(fds[1]);
657 -
658 - fd_set rset;
659 -
660 - char data[1024];
661 -
662 - pid_t sndpid = -1;
663 - int harvested = 1;
664 -
665 - while (1) {
666 - FD_ZERO(&rset);
667 - FD_SET(read_sock, &rset);
668 - //char *end;
669 -
670 - memset(data, 0, 1024);
671 -
672 - if (harvested == 0) {
673 - // We consider a wait error to be a sign that the child pid died
674 - // so we flag it as harvested and keep on going
675 - pid_t harvestpid = waitpid(sndpid, NULL, WNOHANG);
676 - if (harvestpid == -1 || harvestpid == sndpid)
677 - harvested = 1;
678 - }
679 -
680 - struct timeval tm;
681 - tm.tv_sec = 1;
682 - tm.tv_usec = 0;
683 -
684 - if (select(read_sock + 1, &rset, NULL, NULL, &tm) < 0) {
685 - if (errno != EINTR) {
686 - exit(1);
687 - }
688 - }
689 -
690 - if (FD_ISSET(read_sock, &rset)) {
691 - int ret;
692 - ret = read(read_sock, data, 1024);
693 -
694 - // We'll die off if we get a read error, and we'll let kismet on the
695 - // other side detact that it died
696 - if (ret <= 0 && (errno != EAGAIN && errno != EPIPE))
697 - exit(1);
698 -
699 - data[ret] = '\0';
700 - }
701 -
702 - if (data[0] == '\0')
703 - continue;
704 -
705 - // If we've harvested the process, spawn a new one and watch it
706 - // instead. Otherwise, we just let go of the data we read
707 - if (harvested == 1) {
708 - harvested = 0;
709 - if ((sndpid = fork()) == 0) {
710 - // Only take the first line
711 - char *nl;
712 - if ((nl = strchr(data, '\n')) != NULL)
713 - *nl = '\0';
714 -
715 - // Make sure it's shell-clean
716 - MungeToShell(data, strlen(data));
717 - char spk_call[1024];
718 - snprintf(spk_call, 1024, "echo \"(SayText \\\"%s\\\")\" | %s >/dev/null 2>/dev/null",
719 - data, player);
720 - system(spk_call);
721 -
722 - exit(0);
723 - }
724 - }
725 -
726 - data[0] = '\0';
727 - }
728 -}
729 -
730 -
731 -// Fork and run a system call to play a sound
732 -int PlaySound(string in_sound) {
733 -
734 - char snd[1024];
735 -
736 - snprintf(snd, 1024, "%s\n", in_sound.c_str());
737 -
738 - if (write(soundpair[1], snd, strlen(snd)) < 0) {
739 - char status[STATUS_MAX];
740 - if (!silent)
741 - fprintf(stderr, "ERROR: Write error, closing sound pipe.\n");
742 - snprintf(status, STATUS_MAX, "ERROR: Write error on sound pipe, closing sound connection");
743 - NetWriteStatus(status);
744 -
745 - return 0;
746 - }
747 -
748 - return 1;
749 -}
750 -
751 -int SayText(string in_text) {
752 -
753 - char snd[1024];
754 -
755 - snprintf(snd, 1024, "%s\n", in_text.c_str());
756 - MungeToShell(snd, 1024);
757 -
758 - if (write(speechpair[1], snd, strlen(snd)) < 0) {
759 - char status[STATUS_MAX];
760 - if (!silent)
761 - fprintf(stderr, "ERROR: Write error, closing speech pipe.\n");
762 - snprintf(status, STATUS_MAX, "ERROR: Write error on speech pipe, closing speech connection");
763 - NetWriteStatus(status);
764 -
765 - return 0;
766 - }
767 -
768 - return 1;
769 -}
770 -
771 void KisLocalAlert(const char *in_text) {
772 time_t now = time(0);
773 if (!silent)
774 fprintf(stderr, "ALERT %.24s %s\n", ctime(&now), in_text);
775 -
776 - if (sound == 1)
777 - sound = PlaySound("alert");
778 -
779 }
780
781 void KisLocalStatus(const char *in_status) {
782 @@ -842,15 +605,11 @@
783 if (gpsret == 0 && gpsmode != 0) {
784 if (!silent || NetWriteStatus("Lost GPS signal.") == 0)
785 fprintf(stderr, "Lost GPS signal.\n");
786 - if (sound == 1)
787 - sound = PlaySound("gpslost");
788
789 gpsmode = 0;
790 } else if (gpsret != 0 && gpsmode == 0) {
791 if (!silent || NetWriteStatus("Acquired GPS signal.") == 0)
792 fprintf(stderr, "Acquired GPS signal.\n");
793 - if (sound == 1)
794 - sound = PlaySound("gpslock");
795
796 gpsmode = 1;
797 }
798 @@ -1533,69 +1292,6 @@
799 legal_ipblock_vec.push_back(ipb);
800 }
801
802 - // Process sound stuff
803 - if (conf->FetchOpt("sound") == "true" && sound == -1) {
804 - if (conf->FetchOpt("soundplay") != "") {
805 - sndplay = conf->FetchOpt("soundplay");
806 -
807 - if (conf->FetchOpt("soundopts") != "")
808 - sndplay += " " + conf->FetchOpt("soundopts");
809 -
810 - sound = 1;
811 -
812 - if (conf->FetchOpt("sound_new") != "")
813 - wav_map["new"] = conf->FetchOpt("sound_new");
814 - if (conf->FetchOpt("sound_new_wep") != "")
815 - wav_map["new_wep"] = conf->FetchOpt("sound_new_wep");
816 - if (conf->FetchOpt("sound_traffic") != "")
817 - wav_map["traffic"] = conf->FetchOpt("sound_traffic");
818 - if (conf->FetchOpt("sound_junktraffic") != "")
819 - wav_map["junktraffic"] = conf->FetchOpt("sound_traffic");
820 - if (conf->FetchOpt("sound_gpslock") != "")
821 - wav_map["gpslock"] = conf->FetchOpt("sound_gpslock");
822 - if (conf->FetchOpt("sound_gpslost") != "")
823 - wav_map["gpslost"] = conf->FetchOpt("sound_gpslost");
824 - if (conf->FetchOpt("sound_alert") != "")
825 - wav_map["alert"] = conf->FetchOpt("sound_alert");
826 -
827 - } else {
828 - fprintf(stderr, "ERROR: Sound alerts enabled but no sound playing binary specified.\n");
829 - sound = 0;
830 - }
831 - } else if (sound == -1)
832 - sound = 0;
833 -
834 - /* Added by Shaw Innes 17/2/02 */
835 - /* Modified by Andrew Etter 15/9/02 */
836 - if (conf->FetchOpt("speech") == "true" && speech == -1) {
837 - if (conf->FetchOpt("festival") != "") {
838 - festival = strdup(conf->FetchOpt("festival").c_str());
839 - speech = 1;
840 -
841 - string speechtype = conf->FetchOpt("speech_type");
842 -
843 - if (!strcasecmp(speechtype.c_str(), "nato"))
844 - speech_encoding = SPEECH_ENCODING_NATO;
845 - else if (!strcasecmp(speechtype.c_str(), "spell"))
846 - speech_encoding = SPEECH_ENCODING_SPELL;
847 - else
848 - speech_encoding = SPEECH_ENCODING_NORMAL;
849 -
850 - // Make sure we have encrypted text lines
851 - if (conf->FetchOpt("speech_encrypted") == "" || conf->FetchOpt("speech_unencrypted") == "") {
852 - fprintf(stderr, "ERROR: Speech request but speech_encrypted or speech_unencrypted line missing.\n");
853 - speech = 0;
854 - }
855 -
856 - speech_sentence_encrypted = conf->FetchOpt("speech_encrypted");
857 - speech_sentence_unencrypted = conf->FetchOpt("speech_unencrypted");
858 - } else {
859 - fprintf(stderr, "ERROR: Speech alerts enabled but no path to festival has been specified.\n");
860 - speech = 0;
861 - }
862 - } else if (speech == -1)
863 - speech = 0;
864 -
865 if (conf->FetchOpt("writeinterval") != "") {
866 if (sscanf(conf->FetchOpt("writeinterval").c_str(), "%d", &datainterval) != 1) {
867 fprintf(stderr, "FATAL: Illegal config file value for data interval.\n");
868 @@ -1615,45 +1311,6 @@
869 fprintf(stderr, "WARNING: No client_manuf file specified. Client manufacturers will not be detected.\n");
870 }
871
872 - // Fork and find the sound options
873 - if (sound) {
874 - if (pipe(soundpair) == -1) {
875 - fprintf(stderr, "WARNING: Unable to create pipe for audio. Disabling sound.\n");
876 - sound = 0;
877 - } else {
878 - soundpid = fork();
879 -
880 - if (soundpid < 0) {
881 - fprintf(stderr, "WARNING: Unable to fork for audio. Disabling sound.\n");
882 - sound = 0;
883 - } else if (soundpid == 0) {
884 - SoundHandler(soundpair, sndplay.c_str(), wav_map);
885 - exit(0);
886 - }
887 -
888 - close(soundpair[0]);
889 - }
890 - }
891 -
892 - if (speech) {
893 - if (pipe(speechpair) == -1) {
894 - fprintf(stderr, "WARNING: Unable to create pipe for speech. Disabling speech.\n");
895 - speech = 0;
896 - } else {
897 - speechpid = fork();
898 -
899 - if (speechpid < 0) {
900 - fprintf(stderr, "WARNING: Unable to fork for speech. Disabling speech.\n");
901 - speech = 0;
902 - } else if (speechpid == 0) {
903 - SpeechHandler(speechpair, festival);
904 - exit(0);
905 - }
906 -
907 - close(speechpair[0]);
908 - }
909 - }
910 -
911 // Grab the filtering
912 string filter_bit;
913
914 @@ -2172,7 +1829,6 @@
915 break;
916 case 'q':
917 // Quiet
918 - sound = 0;
919 break;
920 case 'v':
921 // version
922 @@ -2781,7 +2437,6 @@
923 snprintf(status, 1024, "%s", TIMESTAMP);
924 kdata.timestamp = status;
925
926 - time_t last_click = 0;
927 int num_networks = 0, num_packets = 0, num_noise = 0, num_dropped = 0;
928
929
930 @@ -2944,38 +2599,9 @@
931
932 tracker.ProcessPacket(info);
933
934 - if (tracker.FetchNumNetworks() > num_networks) {
935 - if (sound == 1)
936 - if (info.wep && wav_map.find("new_wep") != wav_map.end())
937 - sound = PlaySound("new_wep");
938 - else
939 - sound = PlaySound("new");
940 - if (speech == 1) {
941 - string text;
942 -
943 - if (info.wep)
944 - text = ExpandSpeechString(speech_sentence_encrypted, &info,
945 - speech_encoding);
946 - else
947 - text = ExpandSpeechString(speech_sentence_unencrypted,
948 - &info, speech_encoding);
949 -
950 - speech = SayText(MungeToShell(text).c_str());
951 - }
952 - }
953 num_networks = tracker.FetchNumNetworks();
954
955 if (tracker.FetchNumPackets() != num_packets) {
956 - if (cur_time - last_click >= decay && sound == 1) {
957 - if (tracker.FetchNumPackets() - num_packets >
958 - tracker.FetchNumDropped() + localdropnum - num_dropped) {
959 - sound = PlaySound("traffic");
960 - } else {
961 - sound = PlaySound("junktraffic");
962 - }
963 -
964 - last_click = cur_time;
965 - }
966
967 num_packets = tracker.FetchNumPackets();
968 num_noise = tracker.FetchNumNoise();
969 diff -urN kismet-2005-04-R1.old/kismet_server.h kismet-2005-04-R1.dev/kismet_server.h
970 --- kismet-2005-04-R1.old/kismet_server.h 2005-04-03 07:33:42.000000000 +0200
971 +++ kismet-2005-04-R1.dev/kismet_server.h 2005-05-04 21:17:50.000000000 +0200
972 @@ -33,10 +33,6 @@
973 void handle_command(TcpServer *tcps, client_command *cc);
974 int NetWriteStatus(const char *in_status);
975 void NetWriteInfo();
976 -int SayText(string in_text);
977 -int PlaySound(string in_sound);
978 -void SpeechHandler(int *fds, const char *player);
979 -void SoundHandler(int *fds, const char *player, map<string, string> soundmap);
980 void ProtocolAlertEnable(int in_fd);
981 void ProtocolNetworkEnable(int in_fd);
982 void ProtocolClientEnable(int in_fd);
983 diff -urN kismet-2005-04-R1.old/panelfront.cc kismet-2005-04-R1.dev/panelfront.cc
984 --- kismet-2005-04-R1.old/panelfront.cc 2005-04-03 07:33:42.000000000 +0200
985 +++ kismet-2005-04-R1.dev/panelfront.cc 2005-05-04 21:19:03.000000000 +0200
986 @@ -420,8 +420,6 @@
987
988 //cutoff = 0;
989
990 - muted = 0;
991 -
992 // Push blanks into the RRD history vector
993 packet_history.reserve(60 * 5);
994 for (unsigned int x = 0; x < (60 * 5); x++)
995 @@ -678,8 +676,6 @@
996
997 zoomed = 0;
998
999 - muted = 0;
1000 -
1001 if (colorkilled)
1002 WriteStatus("Terminal cannot support colors, turning off color options.");
1003
1004 diff -urN kismet-2005-04-R1.old/panelfront.h kismet-2005-04-R1.dev/panelfront.h
1005 --- kismet-2005-04-R1.old/panelfront.h 2005-04-03 07:33:42.000000000 +0200
1006 +++ kismet-2005-04-R1.dev/panelfront.h 2005-05-04 21:18:48.000000000 +0200
1007 @@ -81,8 +81,6 @@
1008 extern char *KismetIntroText[];
1009
1010 // These are in the kismet_curses.cc main code
1011 -extern int sound;
1012 -extern int speech;
1013 extern unsigned int metric;
1014
1015 class PanelFront : public Frontend {
1016 @@ -383,10 +381,6 @@
1017
1018 int hsize, vsize;
1019
1020 - int old_sound;
1021 - int old_speech;
1022 - int muted;
1023 -
1024 vector<int> packet_history;
1025
1026 float lat, lon, spd, alt, heading;
1027 diff -urN kismet-2005-04-R1.old/panelfront_input.cc kismet-2005-04-R1.dev/panelfront_input.cc
1028 --- kismet-2005-04-R1.old/panelfront_input.cc 2005-04-03 07:33:42.000000000 +0200
1029 +++ kismet-2005-04-R1.dev/panelfront_input.cc 2005-05-04 21:18:19.000000000 +0200
1030 @@ -639,21 +639,6 @@
1031 }
1032
1033 void PanelFront::MuteToggle() {
1034 - if (muted) {
1035 - speech = old_speech;
1036 - sound = old_sound;
1037 - muted = 0;
1038 - WriteStatus("Restoring sound");
1039 - } else if (sound != 0 || speech != 0) {
1040 - old_speech = speech;
1041 - old_sound = sound;
1042 - sound = 0;
1043 - speech = 0;
1044 - muted = 1;
1045 - WriteStatus("Muting sound");
1046 - } else if (sound == 0 && speech == 0) {
1047 - WriteStatus("Sound not enabled.");
1048 - }
1049 }
1050
1051 int PanelFront::AlertInput(void *in_window, int in_chr) {
This page took 0.085747 seconds and 5 git commands to generate.