1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 // David Freese, W1HKJ
4 //
5 // This file is part of flmsg
6 //
7 // flrig is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // flrig is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20
21 #include <stdlib.h>
22 #include <iostream>
23 #include <fstream>
24 #include <cstring>
25 #include <ctime>
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdio.h>
29 #include <errno.h>
30
31 #include <FL/Fl.H>
32 #include <FL/Enumerations.H>
33 #include <FL/Fl_Window.H>
34 #include <FL/Fl_Button.H>
35 #include <FL/Fl_Group.H>
36 #include <FL/Fl_Sys_Menu_Bar.H>
37 #include <FL/x.H>
38 #include <FL/Fl_Help_Dialog.H>
39 #include <FL/Fl_Menu_Item.H>
40 #include <FL/Fl_File_Icon.H>
41
42 #include "config.h"
43 #include "flmsg_config.h"
44
45 #include "flmsg.h"
46 #include "templates.h"
47 #include "debug.h"
48 #include "util.h"
49 #include "gettext.h"
50 #include "flmsg_dialog.h"
51 #include "flinput2.h"
52 #include "date.h"
53 #include "calendar.h"
54 #include "icons.h"
55 #include "fileselect.h"
56 #include "wrap.h"
57 #include "status.h"
58 #include "parse_xml.h"
59
60 #ifdef WIN32
61 # include "flmsgrc.h"
62 # include "compat.h"
63 # define dirent fl_dirent_no_thanks
64 #endif
65
66 #include <FL/filename.H>
67 #include "dirent-check.h"
68
69 #include <FL/x.H>
70 #include <FL/Fl_Pixmap.H>
71 #include <FL/Fl_Image.H>
72
73 using namespace std;
74
75 // ics205 fields
76
77 // compatibility fields required to read older data files
78
79 string ics205_name = ":nam:";
80 string ics205_dt1 = ":dt1:";
81 string ics205_dt2 = ":dt2:";
82 string ics205_dt3 = ":dt3:";
83 string ics205_func = ":func";
84 string ics205_chan = ":chan";
85 string ics205_asgn = ":asgn";
86 string ics205_rx_freq = ":rxfq";
87 string ics205_rx_tone = ":rxtn";
88 string ics205_tx_freq = ":txfq";
89 string ics205_tx_tone = ":txtn";
90 string ics205_mode_adm = ":mode";
91 string ics205_rem = ":rmrk";
92 string ics205_prep = ":prp:";
93 string ics205_county = ":cnty:";
94 string ics205_state = ":stat:";
95 string ics205_latitude = ":lat:";
96 string ics205_longitude = ":lon:";
97
98
99 const char *nbr[] = {
100 "00:", "01:", "02:", "03:", "04:", "05:", "06:", "07:", "08:", "09:",
101 "10:", "11:", "12:", "13:", "14:", "15:", "16:", "17:", "18:", "19:" };
102
103 string s205_name;
104 string s205_dt_prepared;
105 string s205_dt_op_from;
106 string s205_dt_op_to;
107 string s205_func[20];
108 string s205_channel[20];
109 string s205_asgn[20];
110 string s205_rx_freq[20];
111 string s205_rx_tone[20];
112 string s205_tx_freq[20];
113 string s205_tx_tone[20];
114 string s205_mode_adm[20];
115 string s205_remarks[20];
116 string s205_preparer;
117 string s205_county;
118 string s205_state;
119 string s205_latitude;
120 string s205_longitude;
121
122 string buff205;
123 string def_205_filename = "";
124 string base_205_filename = "";
125 string def_205_TemplateName = "";
126 bool using_ics205_template = false;
127
cb_205_SetDateTime1()128 void cb_205_SetDateTime1()
129 {
130 txt_205_dt_prepared->value(szDateTime());
131 }
132
cb_205_SetDateTime2()133 void cb_205_SetDateTime2()
134 {
135 txt_205_dt_op_from->value(szDateTime());
136 }
137
cb_205_SetDateTime3()138 void cb_205_SetDateTime3()
139 {
140 txt_205_dt_op_to->value(szDateTime());
141 }
142
clear_205fields()143 void clear_205fields()
144 {
145 s205_name.clear();
146 s205_dt_prepared.clear();
147 s205_dt_op_from.clear();
148 for (int i = 0; i < 20; i++) {
149 s205_func[i].clear();
150 s205_channel[i].clear();
151 s205_asgn[i].clear();
152 s205_rx_freq[i].clear();
153 s205_rx_tone[i].clear();
154 s205_tx_freq[i].clear();
155 s205_tx_tone[i].clear();
156 s205_mode_adm[i].clear();
157 s205_remarks[i].clear();
158 }
159 s205_preparer.clear();
160 s205_county.clear();
161 s205_state.clear();
162 s205_latitude.clear();
163 s205_longitude.clear();
164 }
165
check_205fields()166 bool check_205fields()
167 {
168 if (s205_name != txt_205_name->value())
169 return true;
170 if (s205_dt_prepared != txt_205_dt_prepared->value())
171 return true;
172 if (s205_dt_op_from != txt_205_dt_op_from->value())
173 return true;
174 if (s205_dt_op_to != txt_205_dt_op_to->value())
175 return true;
176 for (int i = 0; i < 20; i++) {
177 if (s205_func[i] != txt_205_func[i]->value())
178 return true;
179 if (s205_channel[i] != txt_205_channel[i]->value())
180 return true;
181 if (s205_asgn[i] != txt_205_assign[i]->value())
182 return true;
183 if (s205_rx_freq[i] != txt_205_rx_freq[i]->value())
184 return true;
185 if (s205_rx_tone[i] != txt_205_rx_tone[i]->value())
186 return true;
187 if (s205_tx_freq[i] != txt_205_tx_freq[i]->value())
188 return true;
189 if (s205_tx_tone[i] != txt_205_tx_tone[i]->value())
190 return true;
191 if (s205_mode_adm[i] != txt_205_mode_adm[i]->value())
192 return true;
193 if (s205_remarks[i] != txt_205_remarks[i]->value())
194 return true;
195 }
196 if (s205_preparer != txt_205_preparer->value())
197 return true;
198 if (s205_county != txt_205_county->value())
199 return true;
200 if (s205_state != txt_205_state->value())
201 return true;
202 if (s205_latitude != txt_205_latitude->value())
203 return true;
204 if (s205_longitude != txt_205_longitude->value())
205 return true;
206
207 return false;
208 }
209
update_205fields()210 void update_205fields()
211 {
212 s205_name = txt_205_name->value();
213 s205_dt_prepared = txt_205_dt_prepared->value();
214 s205_dt_op_from = txt_205_dt_op_from->value();
215 s205_dt_op_to = txt_205_dt_op_to->value();
216 for (int i = 0; i < 20; i++) {
217 s205_func[i] = txt_205_func[i]->value();
218 s205_channel[i] = txt_205_channel[i]->value();
219 s205_asgn[i] = txt_205_assign[i]->value();
220 s205_rx_freq[i] = txt_205_rx_freq[i]->value();
221 s205_rx_tone[i] = txt_205_rx_tone[i]->value();
222 s205_tx_freq[i] = txt_205_tx_freq[i]->value();
223 s205_tx_tone[i] = txt_205_tx_tone[i]->value();
224 s205_mode_adm[i] = txt_205_mode_adm[i]->value();
225 s205_remarks[i] = txt_205_remarks[i]->value();
226 }
227 s205_preparer = txt_205_preparer->value();
228 s205_county = txt_205_county->value();
229 s205_state = txt_205_state->value();
230 s205_latitude = txt_205_latitude->value();
231 s205_longitude = txt_205_longitude->value();
232 }
233
update_205form()234 void update_205form()
235 {
236 txt_205_name->value(s205_name.c_str());
237 txt_205_dt_prepared->value(s205_dt_prepared.c_str());
238 txt_205_dt_op_from->value(s205_dt_op_from.c_str());
239 txt_205_dt_op_to->value(s205_dt_op_to.c_str());
240 for (int i = 0; i < 20; i++) {
241 txt_205_func[i]->value(s205_func[i].c_str());
242 txt_205_channel[i]->value(s205_channel[i].c_str());
243 txt_205_assign[i]->value(s205_asgn[i].c_str());
244 txt_205_rx_freq[i]->value(s205_rx_freq[i].c_str());
245 txt_205_rx_tone[i]->value(s205_rx_tone[i].c_str());
246 txt_205_tx_freq[i]->value(s205_tx_freq[i].c_str());
247 txt_205_tx_tone[i]->value(s205_tx_tone[i].c_str());
248 txt_205_mode_adm[i]->value(s205_mode_adm[i].c_str());
249 txt_205_remarks[i]->value(s205_remarks[i].c_str());
250 }
251 txt_205_preparer->value(s205_preparer.c_str());
252 txt_205_county->value(s205_county.c_str());
253 txt_205_state->value(s205_state.c_str());
254 txt_205_latitude->value(s205_latitude.c_str());
255 txt_205_longitude->value(s205_longitude.c_str());
256 }
257
clear_205_form()258 void clear_205_form()
259 {
260 clear_205fields();
261 txt_205_name->value("");
262 txt_205_dt_prepared->value("");
263 txt_205_dt_op_from->value("");
264 txt_205_dt_op_to->value("");
265 for (int i = 0; i < 20; i++) {
266 txt_205_func[i]->value("");
267 txt_205_channel[i]->value("");
268 txt_205_assign[i]->value("");
269 txt_205_rx_freq[i]->value("");
270 txt_205_rx_tone[i]->value("");
271 txt_205_tx_freq[i]->value("");
272 txt_205_tx_tone[i]->value("");
273 txt_205_mode_adm[i]->value("");
274 txt_205_remarks[i]->value("");
275 }
276 txt_205_preparer->value("");
277 txt_205_county->value("");
278 txt_205_state->value("");
279 txt_205_latitude->value("");
280 txt_205_longitude->value("");
281 }
282
make_buff205(bool compress=false)283 void make_buff205(bool compress = false)
284 {
285 string mbuff;
286 string temp;
287 mbuff.clear();
288 mbuff.append( lineout( ics205_name, s205_name ) );
289 mbuff.append( lineout( ics205_dt1, s205_dt_prepared ) );
290 mbuff.append( lineout( ics205_dt2, s205_dt_op_from ) );
291 mbuff.append( lineout( ics205_dt3, s205_dt_op_to ) );
292
293 for (int i = 0; i < 20; i++) {
294 temp = ics205_func; temp.append(nbr[i]);
295 mbuff.append( lineout ( temp, s205_func[i] ) );
296
297 temp = ics205_chan; temp.append(nbr[i]);
298 mbuff.append( lineout ( temp, s205_channel[i] ) );
299
300 temp = ics205_asgn; temp.append(nbr[i]);
301 mbuff.append( lineout ( temp, s205_asgn[i] ) );
302
303 temp = ics205_rx_freq; temp.append(nbr[i]);
304 mbuff.append( lineout ( temp, s205_rx_freq[i] ) );
305
306 temp = ics205_rx_tone; temp.append(nbr[i]);
307 mbuff.append( lineout ( temp, s205_rx_tone[i] ) );
308
309 temp = ics205_tx_freq; temp.append(nbr[i]);
310 mbuff.append( lineout ( temp, s205_tx_freq[i] ) );
311
312 temp = ics205_tx_tone; temp.append(nbr[i]);
313 mbuff.append( lineout ( temp, s205_tx_tone[i] ) );
314
315 temp = ics205_mode_adm; temp.append(nbr[i]);
316 mbuff.append( lineout ( temp, s205_mode_adm[i] ) );
317
318 temp = ics205_rem; temp.append(nbr[i]);
319 mbuff.append( lineout ( temp, s205_remarks[i] ) );
320 }
321 mbuff.append( lineout ( ics205_prep, s205_preparer ) );
322 mbuff.append( lineout ( ics205_county, s205_county ) );
323 mbuff.append( lineout ( ics205_state, s205_state ) );
324 mbuff.append( lineout ( ics205_latitude, s205_latitude ) );
325 mbuff.append( lineout ( ics205_longitude, s205_longitude ) );
326
327 if (compress) compress_maybe(mbuff);
328 buff205.append(mbuff);
329 }
330
read_205_buffer(string data)331 void read_205_buffer(string data)
332 {
333 string temp;
334 clear_205fields();
335 read_header(data);
336
337 s205_name = findstr(data, ics205_name);
338 s205_dt_prepared = findstr(data, ics205_dt1);
339 s205_dt_op_from = findstr(data, ics205_dt2);
340 s205_dt_op_to = findstr(data, ics205_dt3);
341 for (int i = 0; i < 20; i++) {
342 temp = ics205_func; temp.append(nbr[i]);
343 s205_func[i] = findstr(data, temp);
344
345 temp = ics205_chan; temp.append(nbr[i]);
346 s205_channel[i] = findstr(data, temp);
347
348 temp = ics205_asgn; temp.append(nbr[i]);
349 s205_asgn[i] = findstr(data, temp);
350
351 temp = ics205_rx_freq; temp.append(nbr[i]);
352 s205_rx_freq[i] = findstr(data, temp);
353
354 temp = ics205_rx_tone; temp.append(nbr[i]);
355 s205_rx_tone[i] = findstr(data, temp);
356
357 temp = ics205_tx_freq; temp.append(nbr[i]);
358 s205_tx_freq[i] = findstr(data, temp);
359
360 temp = ics205_tx_tone; temp.append(nbr[i]);
361 s205_tx_tone[i] = findstr(data, temp);
362
363 temp = ics205_mode_adm; temp.append(nbr[i]);
364 s205_mode_adm[i] = findstr(data, temp);
365
366 temp = ics205_rem; temp.append(nbr[i]);
367 s205_remarks[i] = findstr(data, temp);
368 }
369 s205_preparer = findstr(data, ics205_prep);
370 s205_county = findstr(data, ics205_county);
371 s205_state = findstr(data, ics205_state);
372 s205_latitude = findstr(data, ics205_latitude);
373 s205_longitude = findstr(data, ics205_longitude);
374
375 update_205form();
376 }
377
cb_205_new()378 void cb_205_new()
379 {
380 if (check_205fields()) {
381 if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 1) {
382 update_header(CHANGED);
383 cb_205_save();
384 }
385 }
386 clear_205_form();
387 clear_header();
388 def_205_filename = ICS_msg_dir;
389 def_205_filename.append("new").append(F205_EXT);
390 show_filename(def_205_filename);
391 using_ics205_template = false;
392 }
393
cb_205_import()394 void cb_205_import()
395 {
396 fl_alert2("Not implemented");
397 }
398
cb_205_export()399 void cb_205_export()
400 {
401 fl_alert2("Not implemented");
402 }
403
cb_205_wrap_import(string wrapfilename,string inpbuffer)404 void cb_205_wrap_import(string wrapfilename, string inpbuffer)
405 {
406 clear_205_form();
407 read_205_buffer(inpbuffer);
408 def_205_filename = ICS_msg_dir;
409 def_205_filename.append(wrapfilename);
410 show_filename(def_205_filename);
411 using_ics205_template = false;
412 }
413
eval_205_fsize()414 int eval_205_fsize()
415 {
416 Ccrc16 chksum;
417 evalstr.assign("[WRAP:beg][WRAP:lf][WRAP:fn ");
418 evalstr.append(base_205_filename).append("]");
419 update_205fields();
420 update_header(FROM);
421 evalstr.append(header("<ics205>"));
422 buff205.clear();
423 make_buff205(true);
424 if (buff205.empty()) return 0;
425 compress_maybe( buff205 );
426 evalstr.append( buff205 );
427 evalstr.append("[WRAP:chksum ").append(chksum.scrc16(evalstr)).append("][WRAP:end]");
428 return evalstr.length();
429 }
430
cb_205_wrap_export()431 void cb_205_wrap_export()
432 {
433 if (check_205fields()) {
434 if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 0)
435 return;
436 update_header(CHANGED);
437 }
438 update_205fields();
439
440 if (base_205_filename == string("new").append(F205_EXT) ||
441 base_205_filename == string("default").append(F205_EXT) )
442 if (!cb_205_save_as()) return;
443
444 string wrapfilename = WRAP_send_dir;
445 wrapfilename.append(base_205_filename);
446 wrapfilename.append(".wrap");
447 const char *p = FSEL::saveas(
448 "Save as wrap file",
449 "Wrap file\t*.{wrap,WRAP}",
450 wrapfilename.c_str());
451 if (p) {
452 string pext = fl_filename_ext(p);
453 wrapfilename = p;
454 update_header(FROM);
455 buff205.assign(header("<ics205>"));
456 make_buff205(true);
457 export_wrapfile(base_205_filename, wrapfilename, buff205, pext != ".wrap");
458
459 buff205.assign(header("<ics205>"));
460 make_buff205(false);
461 write_205(def_205_filename);
462 }
463 }
464
cb_205_wrap_autosend()465 void cb_205_wrap_autosend()
466 {
467 if (check_205fields()) {
468 if (fl_choice2("Form modified, save?", "No", "Yes", NULL) == 0)
469 return;
470 update_header(CHANGED);
471 }
472 update_205fields();
473
474 if (base_205_filename == string("new").append(F205_EXT) ||
475 base_205_filename == string("default").append(F205_EXT) )
476 if (!cb_205_save_as()) return;
477
478 update_header(FROM);
479 buff205.assign(header("<ics205>"));
480 make_buff205(true);
481 xfr_via_socket(base_205_filename, buff205);
482
483 buff205.assign(header("<ics205>"));
484 make_buff205(false);
485 write_205(def_205_filename);
486 }
487
cb_205_load_template()488 void cb_205_load_template()
489 {
490 string def_205_filename = def_205_TemplateName;
491 const char *p = FSEL::select(
492 "Open template file",
493 string("Template file\t*").append(T205_EXT).c_str(),
494 def_205_filename.c_str());
495 if (p) {
496 clear_205_form();
497 read_data_file(p);
498 def_205_TemplateName = p;
499 show_filename(def_205_TemplateName);
500 using_ics205_template = true;
501 }
502 }
503
cb_205_save_template()504 void cb_205_save_template()
505 {
506 if (!using_ics205_template) {
507 cb_205_save_as_template();
508 return;
509 }
510 string def_205_filename = def_205_TemplateName;
511 const char *p = FSEL::saveas(
512 "Save template file",
513 string("Template file\t*").append(T205_EXT).c_str(),
514 def_205_filename.c_str());
515 if (p) {
516 update_header(CHANGED);
517 buff205.assign(header("<ics205>"));
518 make_buff205();
519 write_205(p);
520 }
521 }
522
cb_205_save_as_template()523 void cb_205_save_as_template()
524 {
525 string def_205_filename = def_205_TemplateName;
526 const char *p = FSEL::saveas(
527 "Save as template file",
528 string("Template file\t*").append(T205_EXT).c_str(),
529 def_205_filename.c_str());
530 if (p) {
531 const char *pext = fl_filename_ext(p);
532 def_205_TemplateName = p;
533 if (strlen(pext) == 0) def_205_TemplateName.append(T205_EXT);
534 remove_spaces_from_filename(def_205_TemplateName);
535 clear_header();
536 update_header(CHANGED);
537 buff205.assign(header("<ics205>"));
538 make_buff205();
539 write_205(def_205_TemplateName);
540 show_filename(def_205_TemplateName);
541 using_ics205_template = true;
542 }
543 }
544
cb_205_open()545 void cb_205_open()
546 {
547 const char *p = FSEL::select(
548 _("Open data file"),
549 string("ICS-205\t*").append(F205_EXT).c_str(),
550 def_205_filename.c_str());
551 if (!p) return;
552 if (strlen(p) == 0) return;
553 clear_205_form();
554 read_data_file(p);
555 using_ics205_template = false;
556 def_205_filename = p;
557 show_filename(def_205_filename);
558 }
559
write_205(string s)560 void write_205(string s)
561 {
562 FILE *file205 = fopen(s.c_str(), "w");
563 if (!file205) return;
564
565 fwrite(buff205.c_str(), buff205.length(), 1, file205);
566 fclose(file205);
567 }
568
cb_205_save_as()569 bool cb_205_save_as()
570 {
571 const char *p;
572 string newfilename;
573
574 string name = named_file();
575 if (!name.empty()) {
576 name.append(F205_EXT);
577 newfilename = ICS_msg_dir;
578 newfilename.append(name);
579 } else
580 newfilename = def_205_filename;
581
582 p = FSEL::saveas(
583 _("Save data file"),
584 string("ICS-205\t*").append(F205_EXT).c_str(),
585 newfilename.c_str());
586
587 if (!p) return false;
588 if (strlen(p) == 0) return false;
589
590 if (progStatus.sernbr_fname) update_sernbr();
591
592 const char *pext = fl_filename_ext(p);
593 def_205_filename = p;
594 if (strlen(pext) == 0) def_205_filename.append(F205_EXT);
595
596 remove_spaces_from_filename(def_205_filename);
597 update_205fields();
598 clear_header();
599 update_header(CHANGED);
600 buff205.assign(header("<ics205>"));
601 make_buff205();
602 write_205(def_205_filename);
603
604 using_ics205_template = false;
605 show_filename(def_205_filename);
606 return true;
607 }
608
cb_205_save()609 void cb_205_save()
610 {
611 if (base_205_filename == string("new").append(F205_EXT) ||
612 base_205_filename == string("default").append(F205_EXT) ||
613 using_ics205_template == true) {
614 cb_205_save_as();
615 return;
616 }
617 if (check_205fields()) update_header(CHANGED);
618 update_205fields();
619 buff205.assign(header("<ics205>"));
620 make_buff205();
621 write_205(def_205_filename);
622 using_ics205_template = false;
623 }
624
cb_205_html()625 void cb_205_html()
626 {
627 string temp;
628 string fname_name = fl_filename_name(def_205_filename.c_str());
629 size_t p = fname_name.rfind('.');
630 if (p != string::npos) fname_name.erase(p);
631
632 string ics205_fname = ICS_dir;
633 ics205_fname.append(fname_name);
634 ics205_fname.append(".html");
635
636 string html_text = "";
637
638 update_205fields();
639 string form205 = ics205_html_template;
640
641 replacestr(form205, TITLE, fname_name);
642 replacestr(form205, ics205_name, s205_name);
643 replacestr(form205, ics205_dt1, s205_dt_prepared);
644 replacestr(form205, ics205_dt2, s205_dt_op_from);
645 replacestr(form205, ics205_dt3, s205_dt_op_to);
646 for (int i = 0; i < 20; i++) {
647 temp = ics205_func; temp.append(nbr[i]); replacestr(form205, temp, s205_func[i]);
648 temp = ics205_chan; temp.append(nbr[i]); replacestr(form205, temp, s205_channel[i]);
649 temp = ics205_asgn; temp.append(nbr[i]); replacestr(form205, temp, s205_asgn[i]);
650 temp = ics205_rx_freq; temp.append(nbr[i]); replacestr(form205, temp, s205_rx_freq[i]);
651 temp = ics205_rx_tone; temp.append(nbr[i]); replacestr(form205, temp, s205_rx_tone[i]);
652 temp = ics205_tx_freq; temp.append(nbr[i]); replacestr(form205, temp, s205_tx_freq[i]);
653 temp = ics205_tx_tone; temp.append(nbr[i]); replacestr(form205, temp, s205_tx_tone[i]);
654 temp = ics205_mode_adm; temp.append(nbr[i]); replacestr(form205, temp, s205_mode_adm[i]);
655 temp = ics205_rem; temp.append(nbr[i]); replacestr(form205, temp, s205_remarks[i]);
656 }
657 replacestr(form205, ics205_prep, s205_preparer);
658 replacestr(form205, ics205_county, s205_county);
659 replacestr(form205, ics205_state, s205_state);
660 replacestr(form205, ics205_latitude, s205_latitude);
661 replacestr(form205, ics205_longitude, s205_longitude);
662
663 FILE *file205 = fopen(ics205_fname.c_str(), "w");
664 fprintf(file205,"%s", form205.c_str());
665 fclose(file205);
666
667 open_url(ics205_fname.c_str());
668 }
669
cb_205_msg_type()670 void cb_205_msg_type()
671 {
672 if (tabs_msg_type->value() == tab_ics205 ) {
673 show_filename(def_205_filename);
674 } else {
675 show_filename(def_rg_filename);
676 }
677 }
678
cb_205_textout()679 void cb_205_textout()
680 {
681 string fld = "";
682 string temp = "";
683 string ics205_fname = ICS_dir;
684 ics205_fname.append("ics205.txt");
685
686 update_205fields();
687 string form205 = ics205_text_template;
688
689 replacestr(form205, ics205_name, s205_name);
690 replacestr(form205, ics205_dt1, s205_dt_prepared);
691 replacestr(form205, ics205_dt2, s205_dt_op_from);
692 replacestr(form205, ics205_dt3, s205_dt_op_to);
693 for (int i = 0; i < 20; i++) {
694 fld = ics205_func; fld.append(nbr[i]); replacestr(form205, fld, s205_func[i]);
695 fld = ics205_chan; fld.append(nbr[i]); replacestr(form205, fld, s205_channel[i]);
696 fld = ics205_asgn; fld.append(nbr[i]); replacestr(form205, fld, s205_asgn[i]);
697 fld = ics205_rx_freq; fld.append(nbr[i]); replacestr(form205, fld, s205_rx_freq[i]);
698 fld = ics205_rx_tone; fld.append(nbr[i]); replacestr(form205, fld, s205_rx_tone[i]);
699 fld = ics205_tx_freq; fld.append(nbr[i]); replacestr(form205, fld, s205_tx_freq[i]);
700 fld = ics205_tx_tone; fld.append(nbr[i]); replacestr(form205, fld, s205_tx_tone[i]);
701 fld = ics205_mode_adm; fld.append(nbr[i]); replacestr(form205, fld, s205_mode_adm[i]);
702 fld = ics205_rem; fld.append(nbr[i]); temp = s205_remarks[i];
703 replacelf(temp); replacestr(form205, fld, temp);
704 }
705 replacestr(form205, ics205_prep, s205_preparer);
706 replacestr(form205, ics205_county, s205_county);
707 replacestr(form205, ics205_state, s205_state);
708 replacestr(form205, ics205_latitude, s205_latitude);
709 replacestr(form205, ics205_longitude, s205_longitude);
710
711 FILE *file205 = fopen(ics205_fname.c_str(), "w");
712 fprintf(file205,"%s", form205.c_str());
713 fclose(file205);
714
715 open_url(ics205_fname.c_str());
716 }
717