void PluginSurprise::OnCron(Bunny * b, QVariant) { if(b->IsIdle()) { QByteArray file; // Fetch available files QDir * dir = GetLocalHTTPFolder(); if(dir) { QString surprise = b->GetPluginSetting(GetName(), "folder", QString()).toString(); if(!surprise.isNull() && dir->cd(surprise)) { QStringList list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { file = GetBroadcastHTTPPath(QString("%1/%3").arg(surprise, list.at(qrand()%list.count()))); QByteArray message = "MU "+file+"\nPL 3\nMW\n"; b->SendPacket(MessagePacket(message)); } } else LogError("Invalid surprise config"); delete dir; } else LogError("Invalid GetLocalHTTPFolder()"); } // Restart Timer createCron(b); }
PluginWeather::PluginWeather():PluginInterface("weather", "Météo",BunnyZtampPlugin) { std::auto_ptr<QDir> dir(GetLocalHTTPFolder()); if(dir.get()) { weatherFolder = *dir; } }
PluginClock::PluginClock():PluginInterface("clock", "Orologio",BunnyPlugin) { Cron::Register(this, 60, 0, 0, NULL); // Check available folders QDir * httpFolder = GetLocalHTTPFolder(); if(httpFolder) { availableVoices = httpFolder->entryList(QDir::Dirs|QDir::NoDotAndDotDot); delete httpFolder; } availableVoices.push_back("tts"); }
void PluginClock::OnCron(Bunny *, QVariant) { QMapIterator<Bunny *, QString> i(bunnyList); while (i.hasNext()) { i.next(); Bunny * b = i.key(); QString voice = i.value(); if(b->IsIdle()) { QString hour = QDateTime::currentDateTime().toString("h"); QByteArray file; if(voice == "tts") // if(voice == "French") // file = TTSManager::CreateNewSound("Il est " + hour + " heure", "julie"); // if(voice == "English") file = TTSManager::CreateNewSound("It is " + hour + " O'Clock", "heather"); else { // Fetch available files QDir * dir = GetLocalHTTPFolder(); if(dir) { dir->cd(voice); dir->cd(hour); QStringList list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { file = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, hour, list.at(qrand()%list.count()))); } delete dir; } else LogError("Invalid GetLocalHTTPFolder()"); } if(!file.isNull()) { QByteArray message = "MU "+file+"\nPL 3\nMW\n"; b->SendPacket(MessagePacket(message)); } } } }
void PluginClock::OnCron(Bunny *, QVariant) { QMapIterator<Bunny *, QString> i(bunnyList); while (i.hasNext()) { i.next(); Bunny * b = i.key(); QString voice = i.value(); if(b->IsIdle()) { QString hour = QDateTime::currentDateTime().toString("h"); QByteArray file; QDir * dir = GetLocalHTTPFolder(); QStringList list; if(voice == "tts") file = TTSManager::CreateNewSound("Sono le ore " + hour, "chiara"); else { // Fetch available files if(dir) { dir->cd(voice); dir->cd(hour); list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { file = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, hour, list.at(qrand()%list.count()))); } delete dir; } else LogError("Invalid GetLocalHTTPFolder()"); } if(!file.isNull()) { QByteArray fileR; dir = GetLocalHTTPFolder(); if (voice == "tts") voice = "violet"; // Directory default respiration TTS QString respiration = "respiration"; // Directory respiration if (dir->cd(voice) && dir->cd(respiration)) { list = dir->entryList(QDir::Files|QDir::NoDotAndDotDot); if(list.count()) { fileR = GetBroadcastHTTPPath(QString("%1/%2/%3").arg(voice, respiration, list.at(qrand()%list.count()))); } } QByteArray message; if(!fileR.isNull()) message = "MU "+fileR+"\nPL 3\nMW\nMU "+file+"\nPL 3\nMW\nMU "+fileR+"\nPL 3\nMW\n"; else message = "MU "+file+"\nPL 3\nMW\n"; b->SendPacket(MessagePacket(message)); } } } }