MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / readAppList

Method readAppList

src/server/nc_apps.cpp:165–216  ·  view source on GitHub ↗

--- READ APP LIST ---

Source from the content-addressed store, hash-verified

163
164// --- READ APP LIST ---
165bool NCApps::readAppList(std::string path) {
166 INIReader appList(path);
167 if (appList.ParseError() != 0) {
168 std::cerr << "Failed to parse the '" << path << "' file." << std::endl;
169 return false;
170 }
171
172 std::set<std::string> sections = appList.Sections();
173
174 // Read out the information per app section.
175 NymphCastApp app;
176 std::set<std::string>::const_iterator it;
177 for (it = sections.cbegin(); it != sections.cend(); ++it) {
178 app.id = appList.Get(*it, "name", "");
179 if (app.id.empty()) {
180 std::cerr << "App name was empty. Skipping..." << std::endl;
181 continue;
182 }
183
184 std::string loc = appList.Get(*it, "location", "");
185 if (loc == "local") {
186 app.location = NYMPHCAST_APP_LOCATION_LOCAL;
187 }
188 else if (loc == "remote") {
189 app.location = NYMPHCAST_APP_LOCATION_HTTP;
190 }
191 else {
192 // Default is to ignore this app.
193 std::cerr << "Invalid location for app " << app.id << ". Ignoring..." << std::endl;
194 continue;
195 }
196
197 app.url = appList.Get(*it, "url", "");
198 if (app.url.empty()) {
199 std::cerr << "Invalid URL for app " << app.id << std::endl;
200 continue;
201 }
202
203 std::cout << "Adding app: " << app.id << std::endl;
204
205 if (!addApp(app.id, app)) { return false; }
206 }
207
208 if (apps.size() > 0) {
209 defaultApp = apps.begin()->second;
210 }
211
212 // TODO: Update apps.html file using the template if apps.ini is newer than the HTML file.
213
214
215 return true;
216}
217
218
219// --- APP NAMES ---

Callers 1

mainFunction · 0.80

Calls 5

ParseErrorMethod · 0.80
GetMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected