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 "flmsg.h"
22 #include "flmsg_dialog.h"
23 #include "status.h"
24
25 ARL_TEXT arl_list[] = {
26 {"ONE", 0, "Everyone safe here. Please don't worry." },
27 {"TWO", 0, "Coming home as soon as possible." },
28 {"THREE", 1, "Am in ____ hospital. Receiving excellent care and recovering fine." },
29 {"FOUR", 0, "Only slight property damage here. Do not be concerned about disaster reports." },
30 {"FIVE", 0, "Am moving to new location. Send no further mail or communication. Will inform you of new address when relocated." },
31 {"SIX", 0, "Will contact you as soon as possible." },
32 {"SEVEN", 0, "Please reply by Amateur Radio through the amateur delivering this message. This is a free public service." },
33 {"EIGHT", 1, "Need additional ____ mobile or portable equipment for immediate emergency use." },
34 {"NINE", 1, "Additional ____ radio operators needed to assist with emergency at this location." },
35 {"TEN", 1, "Please contact ____. Advise to standby and provide further emergency information, instructions or assistance." },
36 {"ELEVEN", 2, "Establish Amateur Radio emergency communications with ____ on ____ MHz." },
37 {"TWELVE", 0, "Anxious to hear from you. No word in some time. Please contact me as soon as possible." },
38 {"THIRTEEN", 0, "Medical emergency situation exits here." },
39 {"FOURTEEN", 1, "Situation here becoming critical. Losses and damage from ____ increasing." },
40 {"FIFTEEN", 0, "Please advise your condition and what help is needed." },
41 {"SIXTEEN", 0, "Property damage very severe in this area." },
42 {"SEVENTEEN", 2, "REACT communications services also available. Establish REACT communication with ____ on channel ____." },
43 {"EIGHTEEN", 1, "Please contact me as soon as possible at ____." },
44 {"NINETEEN", 1, "Request health and welfare report on ____ . (State name, address and telephone number.)" },
45 {"TWENTY", 1, "Temporarily stranded. Will need some assistance. Please contact me at ____." },
46 {"TWENTY ONE", 0, "Search and Rescue assistance is needed by local authorities here. Advise availability." },
47 {"TWENTY TWO", 0, "Need accurate information on the extent and type of conditions now existing at your location. Please furnish this information and reply without delay." },
48 {"TWENTY THREE", 0, "Report at once the accessibility and best way to reach your location." },
49 {"TWENTY FOUR", 0, "Evacuation of residents from this area urgently needed. Advise plans for help." },
50 {"TWENTY FIVE", 0, "Furnish as soon as possible the weather conditions at your location." },
51 {"TWENTY SIX", 0, "Help and care for evacuation of sick and injured from this location needed at once. Emergency/priority messages originating from official sources must carry the signature of the originating official." },
52 {"FORTY SIX", 0, "Greetings on your birthday and best wishes for many more to come." },
53 {"FORTY SEVEN", 4, "Reference your message number ____ to ____ delivered on ____ at ____ UTC." },
54 {"FIFTY", 0, "Greetings by Amateur Radio." },
55 {"FIFTY ONE", 1, "Greetings by Amateur Radio. This message is sent as a free public service by ham radio operators at ____. Am having a wonderful time." },
56 {"FIFTY TWO", 0, "Really enjoyed being with you. Looking forward to getting together again." },
57 {"FIFTY THREE", 1, "Received your ____. It's appreciated; many thanks." },
58 {"FIFTY FOUR", 0, "Many thanks for your good wishes." },
59 {"FIFTY FIVE", 0, "Good news is always welcome. Very delighted to hear about yours." },
60 {"FIFTY SIX", 1, "Congratulations on your ____, a most worthy and deserved achievement." },
61 {"FIFTY SEVEN", 0, "Wish we could be together." },
62 {"FIFTY EIGHT", 0, "Have a wonderful time. Let us know when you return." },
63 {"FIFTY NINE", 0, "Congratulations on the new arrival. Hope mother and child are well." },
64 {"SIXTY", 1, "Wishing you the best of everything on ____." },
65 {"SIXTY ONE", 0, "Wishing you a very Merry Christmas and a Happy New Year." },
66 {"SIXTY TWO", 1, "Greetings and best wishes to you for a pleasant ____ holiday season." },
67 {"SIXTY THREE", 0, "Victory or defeat, our best wishes are with you. Hope you win." },
68 {"SIXTY FOUR", 1, "Arrived safely at ____." },
69 {"SIXTY FIVE", 2, "Arriving ____ on ____. Please arrange to meet me there." },
70 {"SIXTY SIX", 2, "DX QSLs are on hand for you at the ____ QSL Bureau. Send ____ self addressed envelopes." },
71 {"SIXTY SEVEN", 2, "Your message number ____ undeliverable because of ____. Please advise." },
72 {"SIXTY EIGHT", 0, "Sorry to hear you are ill. Best wishes for a speedy recovery." },
73 {"SIXTY NINE", 1, "Welcome to the ____. We are glad to have you with us and hope you will enjoy the fun and fellowship of the organization." },
74 {0, 0, 0}
75 };
76
77 int arl_nbr = 0;
78
cb_arl()79 void cb_arl()
80 {
81 if (!arlwindow) {
82 arlwindow = arl_dialog();
83 int n = 0;
84 while (arl_list[n].sznbr) {
85 select_arl->add(arl_list[n].sznbr);
86 n++;
87 }
88 }
89 select_arl->value(1);
90 select_arl->do_callback();
91 arlwindow->show();
92 }
93
cb_arl_cancel()94 void cb_arl_cancel()
95 {
96 arlwindow->hide();
97 }
98
cb_arl_add()99 void cb_arl_add()
100 {
101 string msg = "ARL ";
102 string fill;
103 msg.append(arl_list[arl_nbr].sznbr).append(progStatus.insert_x ? " X " : " ");
104 fill = txt_arl_fill1->value(); if (!fill.empty()) msg.append(fill).append(progStatus.insert_x ? " X " : " ");
105 fill = txt_arl_fill2->value(); if (!fill.empty()) msg.append(fill).append(progStatus.insert_x ? " X " : " ");
106 fill = txt_arl_fill3->value(); if (!fill.empty()) msg.append(fill).append(progStatus.insert_x ? " X " : " ");
107 fill = txt_arl_fill4->value(); if (!fill.empty()) msg.append(fill).append(progStatus.insert_x ? " X " : " ");
108 txt_rg_msg->addstr(msg.c_str());
109 select_arl->value(1);
110 select_arl->do_callback();
111 cb_rg_check();
112 }
113
expand_arl(std::string & s)114 std::string expand_arl(std::string &s)
115 {
116 size_t p = 0;
117 std::string text = s;
118 std::string retstr = "";
119 int num = sizeof(arl_list) / sizeof(ARL_TEXT);
120 for (size_t n = 0; n < text.length(); n++)
121 if (text[n] == '\n') text[n] = ' ';
122 while ((p = text.find(" ")) != std::string::npos)
123 text.erase(p,1);
124 p = text.find("ARL");
125 while (p != std::string::npos) {
126 p += 3;
127 while (text[p] == ' ') p++;
128 for (int i = num - 2; i >= 0; i--) {
129 if (text.find(arl_list[i].sznbr, p) == p) {
130 char arlstr[50];
131 snprintf(arlstr, sizeof(arlstr), "ARL %s: ", arl_list[i].sznbr);
132 retstr.append(arlstr);
133 retstr.append(arl_list[i].text).append("<br>");
134 break;
135 }
136 }
137 p = text.find("ARL", p+1);
138 }
139 return retstr;
140 }
141