| 7 | #include <QCoreApplication> |
| 8 | |
| 9 | Router::Router(QObject *parent) : stefanfrings::HttpRequestHandler(parent) |
| 10 | { |
| 11 | apiHandler = new APIHandler(this); |
| 12 | fileHandler = new FileHandler(this); |
| 13 | const QString strApp(QCoreApplication::applicationDirPath()+"/web"); |
| 14 | #ifdef CONFIG_UNIX_DATA |
| 15 | const QString strHome(QDir::homePath()+"/.config/kikoplay/web"); |
| 16 | const QString strSys("/usr/share/kikoplay/web"); |
| 17 | |
| 18 | const QFileInfo fileinfoHome(strHome); |
| 19 | const QFileInfo fileinfoSys(strSys); |
| 20 | const QFileInfo fileinfoApp(strApp); |
| 21 | |
| 22 | if (fileinfoHome.exists() || fileinfoHome.isDir()) { |
| 23 | fileHandler->setRoot(strHome); |
| 24 | } else if (fileinfoSys.exists() || fileinfoSys.isDir()) { |
| 25 | fileHandler->setRoot(strSys); |
| 26 | } else { |
| 27 | fileHandler->setRoot(strApp); |
| 28 | } |
| 29 | #else |
| 30 | fileHandler->setRoot(strApp); |
| 31 | #endif |
| 32 | } |
| 33 | |
| 34 | void Router::service(stefanfrings::HttpRequest &request, stefanfrings::HttpResponse &response) |
| 35 | { |