--- READ APP LIST ---
| 163 | |
| 164 | // --- READ APP LIST --- |
| 165 | bool 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 --- |