Ticket #3938: mythweather.patch
File mythweather.patch, 4.0 KB (added by , 17 years ago) |
---|
-
mythplugins/mythweather/mythweather/sourceManager.h
40 40 QPtrList<WeatherSource> m_sources; //in-use scripts 41 41 QIntDict<WeatherSource> m_sourcemap; 42 42 units_t m_units; 43 void recurseDirs(QDir dir); 43 44 }; 44 45 45 46 #endif -
mythplugins/mythweather/mythweather/weatherSource.cpp
386 386 QStringList locs; 387 387 388 388 m_proc->clearArguments(); 389 m_proc->setWorkingDirectory(m_info->file->dir(true)); 389 390 m_proc->addArgument(m_info->file->absFilePath()); 390 391 m_proc->addArgument("-l"); 391 392 m_proc->addArgument(str); … … 421 422 VERBOSE(VB_GENERAL, "Starting update of " + m_info->name); 422 423 m_data.clear(); 423 424 m_proc->clearArguments(); 425 m_proc->setWorkingDirectory(m_info->file->dir(true)); 424 426 m_proc->addArgument("nice"); 425 427 m_proc->addArgument(m_info->file->absFilePath()); 426 428 m_proc->addArgument("-u"); -
mythplugins/mythweather/mythweather/sourceManager.cpp
71 71 { 72 72 QString path = gContext->GetShareDir() + "mythweather/scripts/"; 73 73 QDir dir(path); 74 dir.setFilter(QDir::Executable | QDir::Files );74 dir.setFilter(QDir::Executable | QDir::Files | QDir::Dirs); 75 75 // this kinda goes against idea of keeping ui separate, but oh well 76 MythProgressDialog bsydlg(tr("Searching for scripts"), dir.count()); 77 int progress = 0; 76 MythProgressDialog bsydlg(tr("Searching for scripts"), 1); 78 77 79 78 if (!dir.exists()) 80 79 { … … 82 81 return false; 83 82 } 84 83 85 const QFileInfoList *files = dir.entryInfoList();86 if (!files)87 return false;84 bsydlg.setProgress(0); 85 recurseDirs(dir); 86 bsydlg.setProgress(1); 88 87 89 QFileInfoListIterator itr(*files);90 QFileInfo *file;91 while ((file = itr.current()))92 {93 ++itr;94 if (file->isExecutable())95 {96 ScriptInfo *info = WeatherSource::probeScript(*file);97 if (info)98 {99 m_scripts.append(info);100 VERBOSE(VB_GENERAL, "found script " + file->absFilePath());101 }102 }103 bsydlg.setProgress(++progress);104 }105 88 // run through and see if any scripts have been deleted 106 89 MSqlQuery db(MSqlQuery::InitCon()); 107 90 QString query = "SELECT sourceid, path FROM weathersourcesettings " … … 307 290 WeatherSource *ws = m_sourcemap[screen->getId()]; 308 291 ws->disconnectScreen(screen); 309 292 } 293 294 // Recurses dir for script files 295 void SourceManager::recurseDirs( QDir dir ) 296 { 297 if (!dir.exists()) 298 return; 299 300 dir.setFilter(QDir::Executable | QDir::Files | QDir::Dirs); 301 const QFileInfoList *files = dir.entryInfoList(); 302 if (!files) 303 return; 304 305 QFileInfoListIterator itr(*files); 306 QFileInfo *file; 307 308 while ((file = itr.current())) 309 { 310 ++itr; 311 if (file->isDir()) 312 { 313 if (file->fileName() == QString("..")) continue; 314 if (file->fileName() == QString(".")) continue; 315 QDir recurseTo(file->filePath()); 316 recurseDirs(recurseTo); 317 } 318 319 if (file->isExecutable() && !(file->isDir())) 320 { 321 ScriptInfo *info = WeatherSource::probeScript(*file); 322 if (info) 323 { 324 m_scripts.append(info); 325 VERBOSE(VB_GENERAL, "found script " + file->absFilePath()); 326 } 327 } 328 } 329 330 return; 331 }