GCC Code Coverage Report


Directory: ./
File: oled/FPPMainMenu.cpp
Date: 2026-12-01 12:27:28
Exec Total Coverage
Lines: 174 326 53.4%
Functions: 15 30 50.0%
Branches: 184 602 30.6%

Line Branch Exec Source
1 #include "fpp-pch.h"
2
3 #include "fpp-json.h"
4
5 #include <net/if.h>
6 #include <unistd.h>
7
8 #include "FPPMainMenu.h"
9 #include "../Warnings.h"
10 #include "../common.h"
11 #include "../fppversion.h"
12 #include "../log.h"
13 #include "../settings.h"
14 #include "../CurlSocket.h"
15
16 #include "FPPStatusOLEDPage.h"
17 #include "NetworkOLEDPage.h"
18
19 ✗ static int curlBufferWriter(char* data, size_t size, size_t nmemb,
20 std::string* writerData) {
21 ✗ if (writerData == NULL) {
22 ✗ return 0;
23 }
24 ✗ writerData->append(data, size * nmemb);
25 ✗ return size * nmemb;
26 }
27
28 ✗ static std::string escapeURL(const std::string& url) {
29 ✗ CURL* curl = curl_easy_init();
30 ✗ curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
31 ✗ char* output = curl_easy_escape(curl, url.c_str(), url.length());
32 ✗ std::string ret = output;
33 ✗ curl_free(output);
34 ✗ curl_easy_cleanup(curl);
35 ✗ return ret;
36 ✗ }
37
38 6 static std::string doCurlGet(const std::string& url, int timeout = 250) {
39 6 const std::string buffer;
40
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 CURL* curl = curl_easy_init();
41
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 SetCurlCloseOnExec(curl);
42
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
43
44
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
45
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
46
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout);
47
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curlBufferWriter);
48
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
49
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_perform(curl);
50
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 curl_easy_cleanup(curl);
51 6 return buffer;
52 ✗ }
53
54 // For the routes that change state, which take POST (GET is deprecated).
55 2 static std::string doCurlPost(const std::string& url, int timeout = 250) {
56 2 std::string resp;
57
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
6 urlHelper("POST", url, "", resp, (timeout + 999) / 1000);
58 2 return resp;
59 ✗ }
60
61 class RebootPromptPage : public PromptOLEDPage {
62 public:
63 ✗ RebootPromptPage(OLEDPage* p) :
64 PromptOLEDPage("Reboot?", "Reboot FPPD?", "", { "OK", "Cancel" }),
65 ✗ parent(p) {}
66 1 RebootPromptPage(const std::string& msg1, const std::string& msg2, OLEDPage* p) :
67 PromptOLEDPage("Reboot?", msg1, msg2, { "OK", "Cancel" }),
68
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
5 parent(p) {}
69 ✗ virtual ~RebootPromptPage() {};
70
71 ✗ virtual void ItemSelected(const std::string& item) override {
72 ✗ if (item == "Cancel") {
73 ✗ SetCurrentPage(parent);
74 } else {
75 ✗ SetCurrentPage(nullptr);
76 ✗ clearDisplay();
77 ✗ printString(4, 17, "Rebooting...");
78 ✗ flushDisplay();
79 ✗ sync();
80 ✗ system("/sbin/reboot");
81 }
82 ✗ }
83
84 private:
85 OLEDPage* parent;
86 };
87
88 class ShutdownPromptPage : public PromptOLEDPage {
89 public:
90 ✗ ShutdownPromptPage(OLEDPage* p) :
91 PromptOLEDPage("Shutdown?", "Shutdown FPPD?", "", { "OK", "Cancel" }),
92 ✗ parent(p) {}
93 ShutdownPromptPage(const std::string& msg1, const std::string& msg2, OLEDPage* p) :
94 PromptOLEDPage("Shutdown?", msg1, msg2, { "OK", "Cancel" }),
95 parent(p) {}
96 ✗ virtual ~ShutdownPromptPage() {};
97
98 ✗ virtual void ItemSelected(const std::string& item) override {
99 ✗ if (item == "Cancel") {
100 ✗ SetCurrentPage(parent);
101 } else {
102 ✗ SetCurrentPage(nullptr);
103 ✗ clearDisplay();
104 ✗ printString(4, 17, "Shutdown...");
105 ✗ flushDisplay();
106 ✗ sync();
107 ✗ system("/sbin/shutdown -h now");
108 }
109 ✗ }
110
111 private:
112 OLEDPage* parent;
113 };
114
115 class BridgeStatsPage : public ListOLEDPage {
116 public:
117 ✗ BridgeStatsPage(OLEDPage* parent) :
118 ✗ ListOLEDPage("Bridge Stats", {}, parent) {};
119 ✗ virtual ~BridgeStatsPage() {}
120
121 ✗ virtual void displaying() override {
122 ✗ bool on = true;
123 ✗ doIteration(on);
124 ✗ }
125 ✗ virtual bool doIteration(bool& displayOn) override {
126 ✗ std::string d = doCurlGet("http://127.0.0.1:32322/fppd/e131stats", 10000);
127 ✗ Json::Value result;
128 ✗ if (LoadJsonFromString(d, result)) {
129 ✗ items.clear();
130 ✗ items.emplace_back("Univ Pckts Err");
131 ✗ for (int x = 0; x < result["universes"].size(); x++) {
132 ✗ Json::Value u = result["universes"][x];
133 ✗ std::string l = u["id"].asString();
134 ✗ l += ":";
135 ✗ if (l.length() < 8) {
136 ✗ l.append(8 - l.length(), ' ');
137 }
138 ✗ l += u["packetsReceived"].asString();
139 ✗ if (l.length() < 15) {
140 ✗ l.append(15 - l.length(), ' ');
141 }
142 ✗ l += u["errors"].asString();
143 ✗ items.push_back(l);
144 ✗ }
145 ✗ display();
146 }
147 ✗ return false;
148 ✗ }
149
150 private:
151 };
152
153 class ResetPage : public MenuOLEDPage {
154 public:
155 2 ResetPage(OLEDPage* parent) :
156
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
8 MenuOLEDPage("Reset FPP", { "Perform Reset", "Back", "-------------", "All", " Networking", " Configuration", " Outputs", " Settings", " Sequences", " Media", " Playlists", " Schedule" }, parent) {
157 2 this->autoDelete();
158 2 };
159 8 virtual ~ResetPage() {}
160
161 4 virtual void itemSelected(const std::string& item) override {
162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (item == "Back") {
163 ✗ SetCurrentPage(parent);
164 ✗ return;
165
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 } else if (item == "Perform Reset") {
166
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
4 PromptOLEDPage* p = new PromptOLEDPage("Reset FPP?", "Reset FPP?", "", { "No", "Yes" }, [parent = this->parent, it = this->items](const std::string& i) {
167 2 LogInfo(VB_GENERAL, "Item: %s\n", i.c_str());
168
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (i == "No") {
169 1 SetCurrentPage(parent);
170
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 } else if (i == "Yes") {
171 1 performReset(parent, it);
172 }
173
7/16
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
22 });
174 2 p->autoDelete();
175 2 SetCurrentPage(p);
176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (item == "All") {
177 ✗ for (int x = 4; x < items.size(); x++) {
178 ✗ items[x][0] = '*';
179 }
180 ✗ display();
181
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 } else if (item[0] != '-') {
182
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 2 times.
26 for (auto& a : items) {
183
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 22 times.
24 if (a == item) {
184
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 a[0] = item[0] == ' ' ? '*' : ' ';
185 }
186 }
187 2 display();
188 }
189 }
190
191 1 static void performReset(OLEDPage* parent, const std::vector<std::string>& items) {
192 1 std::string areas;
193
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogInfo(VB_GENERAL, "Performing reset\n");
194
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for (int x = 4; x < items.size(); x++) {
195
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if (items[x][0] == '*') {
196
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 std::string i = items[x].substr(2);
197
3/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
2 if (i == "Networking") {
198
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 areas += "networking,";
199
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (i == "Configuration") {
200 ✗ areas += "config,";
201
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (i == "Outputs") {
202 ✗ areas += "channeloutputs,";
203
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (i == "Settings") {
204 ✗ areas += "settings,";
205
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (i == "Sequences") {
206 ✗ areas += "sequences,";
207
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (i == "Media") {
208 ✗ areas += "media,";
209
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (i == "Playlists") {
210 ✗ areas += "playlists,";
211
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 } else if (i == "Schedule") {
212
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 areas += "schedule,";
213 }
214 2 }
215 }
216
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!areas.empty()) {
217
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 areas = areas.substr(0, areas.length() - 1);
218
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogInfo(VB_GENERAL, "Areas: %s\n", areas.c_str());
219
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string url = "http://127.0.0.1/resetConfig.php?areas=" + areas;
220
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogInfo(VB_GENERAL, "Reset URL: %s\n", url.c_str());
221
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string d = doCurlPost(url, 10000);
222
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 LogInfo(VB_GENERAL, "%s\n", d.c_str());
223 1 }
224
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 SetCurrentPage(parent);
225 1 }
226 };
227
228 31 FPPMainMenu::FPPMainMenu(FPPStatusOLEDPage* p) :
229 MenuOLEDPage("Main Menu", { "FPP Mode", "Tethering", "Testing", "Reboot", "Shutdown", "Reset", "About", "Back" }, p),
230 31 aboutPage(nullptr),
231
3/6
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✗ Branch 5 not taken.
124 statusPage(p) {
232 31 }
233 ✗ FPPMainMenu::~FPPMainMenu() {
234 ✗ if (aboutPage) {
235 ✗ delete aboutPage;
236 }
237 ✗ }
238
239 15 void FPPMainMenu::displaying() {
240
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 std::string mode = statusPage->getCurrentMode();
241 15 items.clear();
242
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if (mode == "Bridge") {
243 ✗ items.push_back("Bridge Stats");
244
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
15 } else if (mode != "Remote") {
245
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
45 items.push_back("Start Playlist");
246 }
247
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
30 items.push_back("FPP Mode");
248
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (Has4DirectionControls()) {
249 1 bool hasEth0 = false;
250 struct if_nameindex *if_nidxs, *intf;
251
252 1 if_nidxs = if_nameindex();
253
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (if_nidxs != NULL) {
254
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
3 for (intf = if_nidxs; intf->if_index != 0 || intf->if_name != NULL; intf++) {
255
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
4 std::string n = intf->if_name;
256
3/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
2 if (n == "eth0") {
257 1 hasEth0 = true;
258 }
259 2 }
260 1 if_freenameindex(if_nidxs);
261 }
262
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (hasEth0) {
263
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
3 items.push_back("Network");
264 }
265 }
266
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
30 std::vector<std::string> it = { "Tethering", "Testing", "Reboot", "Shutdown", "Reset", "About", "Back" };
267
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
45 items.insert(std::end(items), std::begin(it), std::end(it));
268
269
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 MenuOLEDPage::displaying();
270 15 }
271
272 static std::vector<std::string> TEST_OPTIONS = {
273 " Enable Multisync", "Off", "White", "Red", "Green", "Blue", "R-G-B Cycle", "R-G-B-W Cycle", "R-G-B-W-N Cycle", "R-G-B Chase", "R-G-B-W Chase", "R-G-B-W-N Chase", "Back"
274 };
275
276 class TestingMenuOLEDPage : public MenuOLEDPage {
277 public:
278 1 TestingMenuOLEDPage(FPPStatusOLEDPage* sp, OLEDPage* parent) :
279
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 MenuOLEDPage("Test", TEST_OPTIONS, parent), statusPage(sp) {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (sp->isMultiSyncTest()) {
281 ✗ items[0][0] = '*';
282 }
283 1 }
284
285 2 virtual void itemSelected(const std::string& item) override {
286 // printf("Item: %s\n", item.c_str());
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (item == " Enable Multisync") {
288 ✗ items[0][0] = '*';
289 ✗ statusPage->setMultiSyncTest(true);
290 ✗ display();
291 ✗ return;
292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (item == "*Enable Multisync") {
293 ✗ items[0][0] = ' ';
294 ✗ statusPage->setMultiSyncTest(false);
295 ✗ display();
296 ✗ return;
297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (item == "Back") {
298 ✗ SetCurrentPage(parent);
299 ✗ return;
300 }
301 2 statusPage->runTest(item, statusPage->isMultiSyncTest());
302
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (item == "Off") {
303 1 SetCurrentPage(statusPage);
304 1 return;
305 }
306 }
307
308 FPPStatusOLEDPage* statusPage;
309 };
310
311 11 void FPPMainMenu::itemSelected(const std::string& item) {
312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (item == "Back") {
313 ✗ SetCurrentPage(parent);
314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 } else if (item == "About") {
315 ✗ if (aboutPage == nullptr) {
316 ✗ std::string ver = "Version: ";
317 ✗ ver += getFPPMajorVersion();
318 ✗ ver += ".";
319 ✗ ver += getFPPMinorVersion();
320 ✗ std::string branch = "Branch: ";
321 ✗ branch += getFPPBranch();
322 ✗ aboutPage = new ListOLEDPage("About FPP", { ver, branch }, this);
323 ✗ }
324 ✗ SetCurrentPage(aboutPage);
325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 } else if (item == "Reboot") {
326 ✗ RebootPromptPage* pg = new RebootPromptPage(this);
327 ✗ pg->autoDelete();
328 ✗ SetCurrentPage(pg);
329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 } else if (item == "Shutdown") {
330 ✗ ShutdownPromptPage* pg = new ShutdownPromptPage(this);
331 ✗ pg->autoDelete();
332 ✗ SetCurrentPage(pg);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 } else if (item == "Network") {
334 ✗ FPPNetworkOLEDPage* pg = new FPPNetworkOLEDPage(this);
335 ✗ SetCurrentPage(pg);
336
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 9 times.
11 } else if (item == "Reset") {
337
2/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 ResetPage* pg = new ResetPage(this);
338 2 SetCurrentPage(pg);
339
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 } else if (item == "Testing") {
340 1 FPPStatusOLEDPage* sp = statusPage;
341
2/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 TestingMenuOLEDPage* pg = new TestingMenuOLEDPage(sp, this);
342 1 pg->autoDelete();
343 1 SetCurrentPage(pg);
344
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 } else if (item == "Tethering") {
345 1 FPPStatusOLEDPage* sp = statusPage;
346 std::vector<std::string> options = {
347 " Automatic",
348 " On",
349 " Off",
350 " Back"
351
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
2 };
352
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int tm = getSettingInt("EnableTethering");
353 1 options[tm][0] = '*';
354 MenuOLEDPage* pg = new MenuOLEDPage(
355 ✗ "Tethering", options, [this, sp](const std::string& item) {
356
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (item != " Back") {
357
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string nitem = item.substr(1);
358 1 std::string nvdata;
359 1 std::string nvresults;
360
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string nv = "http://127.0.0.1/api/settings/EnableTethering";
361
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (nitem == "Automatic") {
362 ✗ nvdata = std::string("0");
363
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 } else if (nitem == "On") {
364 ✗ nvdata = std::string("1");
365
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 } else if (nitem == "Off") {
366
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
2 nvdata = std::string("2");
367 } else {
368 ✗ nvdata = std::string("0");
369 }
370
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 urlPut(nv, nvdata, nvresults);
371
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
2 nvdata = std::string("1");
372
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
3 urlPut("http://127.0.0.1/api/settings/rebootFlag", "1", nvresults);
373
374
5/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5 RebootPromptPage* pg = new RebootPromptPage("Reboot Required", "Reboot FPPD?", this);
375 1 pg->autoDelete();
376
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 SetCurrentPage(pg);
377 1 } else {
378 ✗ SetCurrentPage(this);
379 }
380 1 },
381
4/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3 this);
382 1 pg->autoDelete();
383
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 SetCurrentPage(pg);
384
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
8 } else if (item == "FPP Mode") {
385 1 FPPStatusOLEDPage* sp = statusPage;
386 std::vector<std::string> options = {
387 " Player",
388 " Remote",
389 " Back"
390
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
2 };
391
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string mode = statusPage->getCurrentMode();
392
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (mode == "Remote") {
393 ✗ options[1][0] = '*';
394 } else {
395 1 options[0][0] = '*';
396 }
397 MenuOLEDPage* pg = new MenuOLEDPage(
398 ✗ "FPPD Mode", options, [this, sp](const std::string& item) {
399
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (item != " Back") {
400
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string nitem = item.substr(1);
401
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 std::string nv = "player";
402
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if (nitem == "Remote") {
403
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 nv = "remote";
404 }
405 1 std::string nvresults;
406
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
2 urlPut("http://127.0.0.1/api/settings/fppMode", nv, nvresults);
407
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 doCurlPost("http://127.0.0.1/api/system/fppd/restart", 10000);
408
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 SetCurrentPage(sp);
409 1 } else {
410 ✗ SetCurrentPage(this);
411 }
412 1 },
413
4/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
3 this);
414 1 pg->autoDelete();
415
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 SetCurrentPage(pg);
416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
7 } else if (item == "Bridge Stats") {
417 ✗ BridgeStatsPage* pg = new BridgeStatsPage(this);
418 ✗ pg->autoDelete();
419 ✗ SetCurrentPage(pg);
420
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 } else if (item == "Start Playlist") {
421
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 std::string d = doCurlGet("http://127.0.0.1/api/playlists/playable", 10000);
422
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 Json::Value result;
423
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if (LoadJsonFromString(d, result)) {
424 ✗ std::vector<std::string> playlists;
425 ✗ playlists.push_back("-Stop Now-");
426 ✗ playlists.push_back("-Stop Gracefully-");
427 ✗ for (int x = 0; x < result.size(); x++) {
428 ✗ playlists.push_back(result[x].asString());
429 }
430 ✗ playlists.push_back("Back");
431 ✗ FPPStatusOLEDPage* sp = statusPage;
432 MenuOLEDPage* pg = new MenuOLEDPage(
433 ✗ "Playlist", playlists, [sp](const std::string& item) {
434 ✗ if (item == "-Stop Now-") {
435 ✗ std::string url = "http://127.0.0.1/api/playlists/stop";
436 ✗ doCurlPost(url, 1000);
437 ✗ } else if (item == "-Stop Gracefully-") {
438 ✗ std::string url = "http://127.0.0.1/api/playlists/stopgracefully";
439 ✗ doCurlPost(url, 1000);
440 ✗ } else if (item != "Back") {
441 ✗ std::string escItem = escapeURL(item);
442 ✗ std::string url = "http://127.0.0.1/api/playlist/" + escItem + "/start";
443 ✗ doCurlPost(url, 1000);
444 ✗ }
445 ✗ SetCurrentPage(sp);
446 ✗ },
447 ✗ this);
448 ✗ pg->autoDelete();
449 ✗ SetCurrentPage(pg);
450 ✗ }
451 6 }
452
0/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11 }
453