7 #include <QApplication>
21 #define LOC QString("SourceManager: ")
22 #define LOC_ERR QString("SourceManager Error: ")
39 "SELECT DISTINCT wss.sourceid, source_name, update_timeout, "
40 "retrieve_timeout, path, author, version, email, types "
41 "FROM weathersourcesettings wss "
42 "LEFT JOIN weatherdatalayout wdl "
43 "ON wss.sourceid = wdl.weathersourcesettings_sourceid "
44 "WHERE hostname = :HOST;";
56 QFileInfo fi(db.
value(4).toString());
58 if (!fi.isExecutable())
69 si->
path = fi.absolutePath();
70 si->
program = fi.absoluteFilePath();
83 QString path =
GetShareDir() +
"mythweather/scripts/";
85 dir.setFilter(QDir::Executable | QDir::Files | QDir::Dirs);
89 LOG(VB_GENERAL, LOG_ERR,
"MythWeather: Scripts directory not found");
92 QString busymessage = tr(
"Searching for scripts");
95 if (popupStack == NULL)
99 "mythweatherbusydialog");
111 qApp->processEvents();
118 db.
prepare(
"SELECT sourceid, path FROM weathersourcesettings "
119 "WHERE hostname = :HOST;");
123 QStringList toRemove;
126 QFileInfo fi(db.
value(1).toString());
127 if (!fi.isExecutable())
129 toRemove << db.
value(0).toString();
130 LOG(VB_GENERAL, LOG_ERR, QString(
"'%1' no longer exists")
131 .arg(fi.absoluteFilePath()));
135 db.
prepare(
"DELETE FROM weathersourcesettings WHERE sourceid = :ID;");
136 for (
int i = 0; i < toRemove.count(); ++i)
170 "SELECT DISTINCT location, weathersourcesettings_sourceid, "
171 " weatherscreens.units, weatherscreens.screen_id "
172 "FROM weatherdatalayout,weatherscreens "
173 "WHERE weatherscreens.screen_id = weatherscreens_screen_id AND "
174 " weatherscreens.hostname = :HOST");
186 QString loc = db.
value(0).toString();
202 if (src->
name == name)
210 LOG(VB_GENERAL, LOG_ERR,
"No Source found for " + name);
219 return QStringList();
259 LOG(VB_GENERAL, LOG_ERR,
LOC +
260 QString(
"NeedSourceFor: Unable to find source for %1, %2, %3")
261 .arg(
id).arg(loc).arg(units));
297 QList<ScriptInfo *> &sources)
304 QStringList stypes = si->
types;
307 for (i = 0; i < types.count() && handled; ++i)
309 handled = stypes.contains(types[i]);
325 LOG(VB_GENERAL, LOG_ERR,
LOC +
326 QString(
"Cannot connect nonexistent screen 0x%1")
327 .arg((uint64_t)screen,0,16));
335 LOG(VB_GENERAL, LOG_ERR,
LOC +
336 QString(
"Cannot connect nonexistent source '%1'").arg(
id));
350 LOG(VB_GENERAL, LOG_ERR,
LOC +
351 QString(
"Cannot disconnect nonexistent screen 0x%1")
352 .arg((uint64_t)screen,0,16));
360 LOG(VB_GENERAL, LOG_ERR,
LOC +
361 QString(
"Cannot disconnect nonexistent source %1")
362 .arg(screen->
getId()));
378 dir.setFilter(QDir::Executable | QDir::Files | QDir::Dirs |
379 QDir::NoDotAndDotDot);
380 QFileInfoList files = dir.entryInfoList();
383 for (
int x = 0;
x < files.size();
x++)
385 qApp->processEvents();
389 QDir recurseTo(file.filePath());
393 if (file.isExecutable() && !(file.isDir()))
399 LOG(VB_FILE, LOG_INFO, QString(
"Found Script '%1'")
400 .arg(file.absoluteFilePath()));