Пример #1
0
bool PluginEars::OnEarsMove(Bunny * b, int l, int r) {
	/* Get Setting */
	QByteArray Friend = b->GetPluginSetting(GetName(), "Friend", "").toByteArray();
	QString FName(Friend);
	/* If setting set */
	if(!Friend.isEmpty()) {
		Bunny *f = BunnyManager::GetBunny(this, Friend);
			/* If aFriend is found */
			if(f) {
				/* If this bunny is the Friend's friend */
				if(f->GetPluginSetting(GetName(), "Friend", "").toByteArray() == b->GetID()) {
					/* If the friend is connected and not sleeping */
					if(f->IsConnected() && !f->IsSleeping()) {
						/* Debug
					    LogDebug(QString("Friend: %1 Ears to: %2 - %3").arg(FName).arg(l).arg(r)); */
						/* Send A packet to move the ears */
						AmbientPacket p;
						p.SetEarsPosition(l, r);
						f->SendPacket(p);
					}
				}
			}
	}

	return true;
}
Пример #2
0
void PluginGmail::readData(const QHttpResponseHeader &resp)
{
	Bunny * bunny = BunnyManager::GetBunny(this, http.property("BunnyID").toByteArray());

	if (resp.statusCode() != 200)
	{
		http.abort();
		LogWarning("Connection error");
	}
	else
	{
		xml.addData(http.readAll());

		while (!xml.atEnd()) 
		{
			xml.readNext();
			if (xml.isStartElement())
			{
				currentTag = xml.name().toString();
			}
			else if (xml.isCharacters() && !xml.isWhitespace())
			{
				if (currentTag == "fullcount")
				{
					bool ok;
					emailsCount = xml.text().toString().toInt(&ok);
					if (emailsCount > 0)
					{
						bunny->SendPacket(AmbientPacket(AmbientPacket::Service_Nose, 1));

					}
					else
					{
						bunny->SendPacket(AmbientPacket(AmbientPacket::Service_Nose, 0));
					}
				}
			}
    		}
	}
}
Пример #3
0
void PluginWizzflux::analyse(QNetworkReply* networkReply)
{
	if (!networkReply->error()) {
		Bunny * bunny = BunnyManager::GetBunny(this, networkReply->parent()->property("BunnyID").toByteArray());
		if(bunny) {
            QString message = QString::fromUtf8(networkReply->readAll());
        	if(message != "" && bunny->IsIdle()) {
                message = "ST "+message.toAscii()+"\nPL "+QString::number(qrand() % 8).toAscii()+"\nMW\n";
                bunny->SendPacket(MessagePacket(message.toAscii()));
            }
		}
	}
	networkReply->deleteLater();
	networkReply->parent()->deleteLater();
}
Пример #4
0
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));
			}
		}

	}
}
Пример #5
0
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));
			}
		}
	}
}