Example #1
0
bool Job::download()
{
    changeStatus(Downloading, "Downloading data.");
    qDebug() << "Saving file to " << osmFile().absoluteFilePath();
    if (osmFile().exists()) {
        QDateTime now = QDateTime::currentDateTime();
        if (osmFile().lastModified().daysTo(now) > 7) {
            qDebug() << "Old file is outdated, re-downloading " << osmFile().absoluteFilePath();
            QFile::remove(osmFile().absoluteFilePath());
        } else {
            qDebug() << "Old file is still ok, reusing" << osmFile().absoluteFilePath();
            return true;
        }
    }

    QProcess wget;
    QStringList arguments;
    QString url = m_region.pbfFile();
    arguments << "-O" << osmFile().absoluteFilePath() << url;
    qDebug() << "Downloading " << url;
    wget.start("wget", arguments);
    wget.waitForFinished(1000 * 60 * 60 * 12); // wait up to 12 hours for download to complete
    if (wget.exitStatus() == QProcess::NormalExit && wget.exitCode() == 0) {
        return true;
    } else {
        qDebug() << "Failed to download " << url;
        QFile::remove(osmFile().absoluteFilePath());
        changeStatus(Error, "Error downloading .osm.pbf file: " + wget.readAllStandardError());
        return false;
    }
}
Example #2
0
/** Is called when this check structure is triggered. This then can cause
 *  a lap to be counted, animation to be started etc.
 */
void CheckStructure::trigger(unsigned int kart_index)
{    
    World* w = World::getWorld();
    LinearWorld* lw = dynamic_cast<LinearWorld*>(w);
    if (lw != NULL)
    {
        lw->getTrackSector(kart_index).setLastTriggeredCheckline(m_index);
    }
    
    switch(m_check_type)
    {
    case CT_NEW_LAP : 
        World::getWorld()->newLap(kart_index); 
        if(UserConfigParams::m_check_debug)
        {
            printf("CHECK: %s new lap %d triggered\n",
                   World::getWorld()->getKart(kart_index)->getIdent().c_str(),
                   m_index);
        }
        changeStatus(m_check_structures_to_change_state, 
                     kart_index, CS_ACTIVATE);
        break;
    case CT_ACTIVATE: 
        changeStatus(m_check_structures_to_change_state,
                     kart_index, CS_ACTIVATE);
        break;
    case CT_TOGGLE:   
        changeStatus(m_check_structures_to_change_state,
                     kart_index, CS_TOGGLE);
        break;
    default: 
        break;
    }   // switch m_check_type
    changeStatus(m_same_group, kart_index, CS_DEACTIVATE);
}   // trigger
Example #3
0
void MaximaSession::currentExpressionChangedStatus(Cantor::Expression::Status status)
{
    MaximaExpression* expression=m_expressionQueue.first();
    qDebug() << expression << status;

    if(m_initState==MaximaSession::Initializing
       && expression->command().contains( QLatin1String("____END_OF_INIT____")))
    {
        qDebug()<<"initialized";
        m_expressionQueue.removeFirst();

        m_initState=MaximaSession::Initialized;
        m_cache.clear();

        runFirstExpression();

        //QTimer::singleShot(0, this, SLOT(killLabels()));
        killLabels();

        changeStatus(Cantor::Session::Done);

        return;
    }


    if(status!=Cantor::Expression::Computing) //The session is ready for the next command
    {
        qDebug()<<"expression finished";
        disconnect(expression, SIGNAL(statusChanged(Cantor::Expression::Status)),
                   this, SLOT(currentExpressionChangedStatus(Cantor::Expression::Status)));

        qDebug()<<"running next command";

        m_expressionQueue.removeFirst();
        if(m_expressionQueue.isEmpty())
        {
            //if we are done with all the commands in the queue,
            //use the opportunity to update the variablemodel (if the last command wasn't already an update, as infinite loops aren't fun)
            QRegExp exp=QRegExp(QRegExp::escape(MaximaVariableModel::inspectCommand).arg(QLatin1String("(values|functions)")));
            QRegExp exp2=QRegExp(QRegExp::escape(MaximaVariableModel::variableInspectCommand).arg(QLatin1String("(values|functions)")));

            if(MaximaSettings::variableManagement()&&!exp.exactMatch(expression->command())&&!exp2.exactMatch(expression->command()))
            {
                m_variableModel->checkForNewFunctions();
                m_variableModel->checkForNewVariables();
            }else
            {
                changeStatus(Cantor::Session::Done);
            }

        }else
        {
            runFirstExpression();
        }
    }

}
Example #4
0
void initWorker(Worker* worker){
	if(worker!=NULL){
		worker->thread=NULL;
		worker->is_stop=false;
		changeStatus(worker,multask_WORKER_STATUS_INITED);
	}
}
Example #5
0
void SageSession::interrupt()
{
    if(!m_expressionQueue.isEmpty())
        m_expressionQueue.first()->interrupt();
    m_expressionQueue.clear();
    changeStatus(Cantor::Session::Done);
}
Example #6
0
void Client::endLogging()
{
    if (status != Logout)
        changeStatus(Logout);

    endSession();
}
Example #7
0
bool CommInterface::openPort(const QString& portname, const QString& baudrate)
{
	QSerialPort* port = new QSerialPort(portname);
	_port = port;
	connect(port, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(handleSerialError(QSerialPort::SerialPortError)));
	_protocol = new Comm::RobotProtocol(port, 0, true);
	_protocol->beQuiet(true);
	_protocol->setDebugMode(true, false, false);

	if (_protocol->open())
	{
		port->setBaudRate(baudrate.toInt());
		port->setFlowControl(QSerialPort::NoFlowControl);
		port->setParity(QSerialPort::NoParity);
		port->setDataBits(QSerialPort::Data8);
		port->setStopBits(QSerialPort::OneStop);
	}
	else
	{
		delete _protocol; _protocol = 0;
		return false;
	}

	_comm = new Comm::RobotCommInterface(_protocol, new Comm::AX12CommManager, 0, this, this);
	changeStatus(true);

	return true;
}
Example #8
0
void Division::setDivisionCoords(const int locNum)
{
    const ushort x = locationCoordinates[locNum][0];
    const ushort y = locationCoordinates[locNum][1];


    xCoordinate = x;
    divisionXcoordinate[divNum] =  x << 3;
    dr.fw.writeOneElementToFile(DIVISION_X_COORD, 2, x << 3, divNum);


    yCoordinate = y;
    divisionYcoordinate[divNum] =  y << 3;
    dr.fw.writeOneElementToFile(DIVISION_Y_COORD, 2, y << 3, divNum);

    prev = locNum;
    divisionPrevious[divNum] = locNum;
    dr.fw.writeOneElementToFile(DIVISION_PREVIOUS, 1, locNum, divNum);

    next = locNum;
    divisionNext[divNum] = locNum;
    dr.fw.writeOneElementToFile(DIVISION_NEXT, 1, locNum, divNum);

    changeStatus(10); // "rest"

    return;
}
void StatusRootAction::changeStatus( const Kopete::Status::Status* status )
{
	Kopete::StatusMessage statusMessage;
	statusMessage.setTitle( status->title() );
	statusMessage.setMessage( status->message() );

	if ( d->account )
	{	// Set status for this account only
		if ( d->filter == UseCategory )
		{
			if ( status->category() != 0x00 )
			{
				OnlineStatusManager *osm = OnlineStatusManager::self();
				Kopete::OnlineStatus oStatus = osm->onlineStatus( d->account->protocol(), status->category() );
				d->account->setOnlineStatus( oStatus, statusMessage, Kopete::Account::KeepSpecialFlags );
			}
			else
			{
				setStatusMessage( statusMessage );
			}
		}
		else
		{
			d->account->setOnlineStatus( d->onlineStatus, statusMessage, Kopete::Account::KeepSpecialFlags );
		}
	}
	else
	{	// Set global status
		if ( status->category() != 0x00 )
			emit changeStatus( status->category(), statusMessage );
		else
			setStatusMessage( statusMessage );
	}
}
Example #10
0
CheckFileHashWidget::CheckFileHashWidget(int Type, QFileInfoList list, QWidget *parent) :
    QWidget(parent), algorithmType(Type)
{
    QLabel *labelHash = new QLabel("File's hash:");
    QLabel *labelInput = new QLabel("Input hash for check:");
    labelIcon = new QLabel();
    compareWithFile = new QPushButton("Compare file");
    hashLine = new QLineEdit();
    inputLine = new QLineEdit();
    hashLine->setReadOnly(true);
    QVBoxLayout *vbox = new QVBoxLayout();
    QHBoxLayout *hbox = new QHBoxLayout();
    hbox->addWidget(inputLine);
    hbox->addWidget(labelIcon);
    connect(this, SIGNAL(statusChanged(QString)), this->parent(), SLOT(changeStatus(QString)));
    hashLine->setText(getHash(list.at(0).absoluteFilePath()));
    vbox->addWidget(labelHash);
    vbox->addWidget(hashLine);
    vbox->addWidget(labelInput);
    vbox->addLayout(hbox);
    vbox->addWidget(compareWithFile);
    setLayout(vbox);
    connect(inputLine, SIGNAL(textChanged(QString)), SLOT(checkLines(QString)));
    connect(compareWithFile, SIGNAL(clicked()), SLOT(compareFileAndLine()));
}
void
YTLocalVideoData::remove()
{
    QMutexLocker lock(&_mutex);

    Q_ASSERT(_status != YTLocalVideo::Initial);
    Q_ASSERT(_inDatabase);

    removeVideoData();
    QFile(_thumbnailPath).remove();

    QSqlQuery q;
    q.prepare("DELETE FROM local_videos WHERE videoId=?");
    q.addBindValue(_videoId);
    executeSqlQuery(q);

    _videoPath.clear();
    _thumbnailPath.clear();
    _thumbnailExt.clear();
    _quality.clear();
    _inDatabase = false;
    changeStatus(YTLocalVideo::Initial);

    emit inDatabaseChanged(false);
}
SysTrayIconWrapper::SysTrayIconWrapper(const MainView& view, const PlayListManager& playlists):
    QObject(),
    mPlaylists(playlists),
    mSystemTrayIcon(QIcon(":/nocturn.png")),
    mSystemTrayMenu(),
    mPlayAction(QIcon::fromTheme("media-playback-start"), tr("Play"), nullptr),
    mStopAction(QIcon::fromTheme("media-playback-stop"), tr("Stop"), nullptr),
    mStatus(SharedTypes::StoppedState)
{
    connect(SettingsManager::getSettingsManager(), SIGNAL(ConfigurationUpdated()), this, SLOT(rebuildMenu()));
    connect(SettingsManager::getSettingsManager(), SIGNAL(ConfigurationUpdated()), this, SLOT(updateTrayVisibility()));
    connect(&mSystemTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &view, SLOT(toggleWindowVisiblity(QSystemTrayIcon::ActivationReason)));

    connect(&mPlaylists, SIGNAL(CurrentSongChanged(const QString&)), this, SLOT(rebuildMenu()));
    connect(&mPlaylists, SIGNAL(ActivePlayListChanged()), this, SLOT(rebuildMenu()));
    connect(&mPlaylists, SIGNAL(TrackListChanged()), this, SLOT(rebuildMenu()));

    connect(&mPlayAction, SIGNAL(triggered(bool)), MainControler::getMainControler(), SLOT(startPlayback()));
    connect(&mStopAction, SIGNAL(triggered(bool)), MainControler::getMainControler(), SLOT(stopPlayback()));

    connect(MainControler::getMainControler(), SIGNAL(StatusChanged(SharedTypes::PlaybackState, SharedTypes::PlaybackState)),
            this, SLOT(changeStatus(SharedTypes::PlaybackState, SharedTypes::PlaybackState)));

    updateTrayVisibility();
    rebuildMenu();
    mSystemTrayIcon.setContextMenu(&mSystemTrayMenu);
}
Example #13
0
void Client::dispatchAction(QString actionType, QXmlStreamAttributes attributes)
{
    if (actionType == "ready") {
        bool outbound = attributes.value("outbound").toString() == "true",
             ready = attributes.value("value").toString() == "true";

        QString status = ready ? "ready" : attributes.value("mode").toString();

        changeStatus(statusText.value(status));
        changePhoneStatus(status, outbound);
    } else if (actionType == "ask-dial-authorization") {
        QString customerId = attributes.value("customerid").toString(),
                destination = attributes.value("destination").toString(),
                campaign = attributes.value("campaign").toString();

        emit askDialAuthorization(destination, customerId, campaign);
    } else if (actionType == "spy") {
        QString agent = attributes.value("agent").toString();

        emit spyAgentPhone(agent);
    } else if (actionType == "status") {
        bool outbound = attributes.value("outbound").toString() == "true",
             ready = attributes.value("ready").toString() == "true";

        QString group = attributes.value("group").toString(),
                extension = attributes.value("extension").toString();

        emit changeAgentStatus(ready ? Ready : NotReady, outbound, extension);

        Q_UNUSED(group)
    }
Example #14
0
void View::MainWindow::createConnections()
{
    connect(_optionsAction, SIGNAL(triggered()), this, SLOT(options()));
    connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
    connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
    connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(_centralWidget, SIGNAL(statusChanged(QString)), this, SLOT(changeStatus(QString)));
}
Example #15
0
void RSession::interrupt()
{
    qDebug()<<"interrupt" << m_rProcess->pid();
    if (m_rProcess->pid())
	kill(m_rProcess->pid(), 2);
    m_expressionQueue.removeFirst();
    changeStatus(Cantor::Session::Done);
}
Example #16
0
void SageSession::reportProcessError(QProcess::ProcessError e)
{
    if(e==QProcess::FailedToStart)
    {
        changeStatus(Cantor::Session::Done);
        emit error(i18n("Failed to start Sage"));
    }
}
void
YTLocalVideoData::downloadResumed()
{
    QMutexLocker lock(&_mutex);

    Q_ASSERT(_status == YTLocalVideo::Paused);
    changeStatus(YTLocalVideo::Queued);
    qDebug() << "Video download resumed, id:" << _videoId;
}
Example #18
0
void Player::collisionWithOther(BaseCharacter* character)
{
	// bullets
	bullets[0].collisionWithOther(character);
	bullets[1].collisionWithOther(character);
	if (character->live)
	{

		float myXLEFT = x;
		float myYTOP = y;
		float myXRIGHT = x + frameWidth;
		float myYBOTTOM = y + frameHeight;

		float xLEFT = character->x+ character->marginX;
		float yTOP = character->y + character->marginY;
		float xRIGHT = character->x + character->frameWidth - character->marginX;
		float yBOTTOM = character->y + character->frameHeight - character->marginY;

		bool horizontal = (xLEFT >= myXLEFT && xLEFT <= myXRIGHT) || (xRIGHT >= myXLEFT && xRIGHT <= myXRIGHT);
		bool vertical = (yTOP >= myYTOP && yTOP <= myYBOTTOM) || (yBOTTOM >= myYTOP && yBOTTOM <= myYBOTTOM);
		if (horizontal && vertical && !blinking)
		{
			if(incerdible && this->live)
			{
				character->KillByShot();
				score += character->score;
				//globalText.floatingScore(character->x, character->y, character->score);
			}
			else if (velY > 0 && this->live && character->killableByJump)
			{
				character->Hit();
				velY = 3;
				dirY = -1;
				if(!character->live)
				{
					score += character->score;
					globalText.floatingScore(character->x, character->y, character->score);
				}
			}
			else
			{
				if(character->CheckIfKillPlayer(this))
				{
					if (currentState == SMALL)
					{
						this->Kill();
					}
					else
					{
						currentState--;
						changeStatus(currentState);
					}
				}
			}
		}
	}
}
Example #19
0
void View::MainWindow::options()
{
    OptionsDialog dialog(this);

    if(dialog.exec() == QDialog::Accepted) {
        changeStatus(tr("Options changes has been saved"));

        unsigned short port = Persistence::PersistenceManager::readConfig("RemotePort", "Session").toInt();
        unsigned short retries = Persistence::PersistenceManager::readConfig("Retries", "Session").toInt();
        long timeout = Persistence::PersistenceManager::readConfig("Timeout", "Session").toInt();

        QtNetSNMP::QSNMPManager *snmpManager = QtNetSNMP::QSNMPManager::instance();
        snmpManager -> setup(port, retries, timeout);
        _centralWidget -> loadMIBTree();

        changeStatus(tr("Changes applied"));
    }
}
Example #20
0
void ProjectorControl::powerOn()
{
	if (m_state == ON) {
		return;
	}

	changeStatus(true);
	emit stateChanged(tr("Starting"));
}
Example #21
0
void MaximaSession::reportProcessError(QProcess::ProcessError e)
{
    qDebug()<<"process error"<<e;
    if(e==QProcess::FailedToStart)
    {
        changeStatus(Cantor::Session::Done);
        emit error(i18n("Failed to start Maxima"));
    }
}
void JagunMSNConnection::loginUser(QString login, QString password)
{
    qDebug() << "JagunMSNConnection :: logando usuario";
    //db.createNewConnection();
    QString xml;
    if ( db.loginUser(login, password) )
    {
        qDebug() << "JagunMSNConnection :: usuario on";
        //Logado
        // pega os ultimos dados do usuario e armazena o id da conexao
        db.setIdConnection(login, getIdConnection());
        JagunMSNContact *userData = db.getData(login);

        QString nickname = userData->getNickname();
        QString message  = userData->getMessage();
        QString image    = userData->getImage();
        int status       = (int) userData->getLastStatus();
        if ( status == (int) JagunMSNContact::ECSOffline  ) {
            status = (int) JagunMSNContact::ECSOnline;
        }

        xml = parserToXML.logOn(login,nickname,message,image,status);

        logged     = true;
        userLogin  = login;
        userStatus = status;
    } else {
        qDebug() << "JagunMSNConnection :: usuario error";
        // Erro
        QString errorStr(tr("Login ou Senha inválida"));
        xml = parserToXML.loginUserError(errorStr);
    }

    QByteArray messageSend;
    messageSend.append(xml);
    send(&messageSend);

    if (logged) {
        JagunMSNContact *userData = db.getData(login);

        QString nickname = userData->getNickname();
        QString message  = userData->getMessage();
        QString image    = userData->getImage();
        int status       = (int) userData->getLastStatus();
        if ( status == (int) JagunMSNContact::ECSOffline  ) {
            status = (int) JagunMSNContact::ECSOnline;
        }
        QStringList sendToo;

        sendAllRequestAddContact();
        changeStatus(nickname,message,image,status,sendToo);
    } else {
        close();
    }
    //db.closeConnection();
}
Example #23
0
void RSession::serverChangedStatus(int status)
{
    qDebug()<<"changed status to "<<status;
    if(status==0)
    {
        if(!m_expressionQueue.isEmpty())
        {
            RExpression* expr=m_expressionQueue.takeFirst();
            qDebug()<<"done running "<<expr<<" "<<expr->command();
        }

        if(m_expressionQueue.isEmpty())
            changeStatus(Cantor::Session::Done);
        else
            runNextExpression();
    }
    else
        changeStatus(Cantor::Session::Running);
}
Example #24
0
void SageSession::appendExpressionToQueue(SageExpression* expr)
{
    m_expressionQueue.append(expr);

    if(m_expressionQueue.size()==1)
    {
        changeStatus(Cantor::Session::Running);
        runFirstExpression();
    }
}
void
YTLocalVideoData::downloadFinished()
{
    QMutexLocker lock(&_mutex);

    Q_ASSERT(QFile(_videoPath).exists());
    Q_ASSERT(QFile(_thumbnailPath).exists());
    changeStatus(YTLocalVideo::Downloaded);
    qDebug() << "Both video data and thumbnail finished downloading for:" << _videoId;
}
void
YTLocalVideoData::videoDownloadFailed()
{
    QMutexLocker lock(&_mutex);

    _videoFile->remove();
    _videoFile.clear();

    changeStatus(YTLocalVideo::Queued);
}
Example #27
0
void MaximaSession::appendExpressionToQueue(MaximaExpression* expr)
{
    m_expressionQueue.append(expr);

    qDebug()<<"queue: "<<m_expressionQueue.size();
    if(m_expressionQueue.size()==1)
    {
        changeStatus(Cantor::Session::Running);
        runFirstExpression();
    }
}
Example #28
0
bool Job::monav()
{
    QString const status = QString("Generating offline routing map from %1 (%2).").arg(osmFile().fileName()).arg(Region::fileSize(osmFile()));
    changeStatus(Routing, status);
    QStringList arguments;
    arguments << "-s=" + m_monavSettings;
    arguments << "-i=" + osmFile().absoluteFilePath();
    arguments << "-o=" + monavDir().absoluteFilePath();
    arguments << "-pi=OpenStreetMap Importer" << "-pro=Contraction Hierarchies";
    arguments << "-pg=GPS Grid" << "-di";
    arguments << "-dro=" + m_transport;
    arguments << "--profile=" + m_profile;
    arguments << "-dd" /*<< "-dc"*/;
    QProcess monav;
    monav.start("monav-preprocessor", arguments);
    monav.waitForFinished(1000 * 60 * 60 * 6); // wait up to 6 hours for monav to convert the data
    if (monav.exitStatus() == QProcess::NormalExit && monav.exitCode() == 0) {
        qDebug() << "Processed osm file for monav";
    } else {
        qDebug() << "monav exiting with status " << monav.exitCode();
        changeStatus(Error, "Routing map conversion failed: " + monav.readAllStandardError());
        return false;
    }

    QFile pluginsFile(monavDir().absoluteFilePath() + "/plugins.ini");
    pluginsFile.open(QFile::WriteOnly | QFile::Truncate);
    QTextStream pluginsStream(&pluginsFile);
    pluginsStream << "[General]\nrouter=Contraction Hierarchies\nrenderer=Mapnik Renderer\ngpsLookup=GPS Grid\naddressLookup=Unicode Tournament Trie\n";
    pluginsFile.close();

    QFileInfo subdir = QFileInfo(monavDir().absoluteFilePath() + "/routing_" + m_transport.toLower());
    if (subdir.exists() && subdir.isDir()) {
        QFileInfoList files = QDir(subdir.absoluteFilePath()).entryInfoList(QDir::Files);
        foreach(const QFileInfo &file, files) {
            if (!QFile::rename(file.absoluteFilePath(), monavDir().absoluteFilePath() + '/' + file.fileName())) {
                changeStatus(Error, "Unable to move monav files to target directory.");
                return false;
            }
        }
        QDir("/").rmdir(subdir.absoluteFilePath());
    } else {
Example #29
0
void SageSession::currentExpressionChangedStatus(Cantor::Expression::Status status)
{
    if(status!=Cantor::Expression::Computing) //The session is ready for the next command
    {
        SageExpression* expr=m_expressionQueue.takeFirst();
        disconnect(expr, 0, this, 0);
        if(m_expressionQueue.isEmpty())
            changeStatus(Cantor::Session::Done);
        runFirstExpression();
    }

}
Example #30
0
void Player::Kill()
{
	if (live)
	{
		Sound::stopBackgroundMusic();
		Sound::play(Sound::MARIO_DIE);
		incerdible = false;
		
		dirY = -1;
		velY = 3;
		lives--;
		live = false;
		startFrame = 3;
		maxFrame = 4;
		curFrame = 3;
	}
	else
	{
		if (y <= HEIGHT + frameHeight)
		{
			velY += dirY * 10.0 / 60.0;	 // gravity
			if (velY <= 0)
				dirY = 1;
			y += dirY * velY;
		}
		else
		{

			for (int i = 3; i >= 0; i--)	// respawning
			{
				if (x > map->checkpoints[i])
				{
					//std::cout << "Respawn " << x << "\n";
					x = map->checkpoints[i];
					y = 13 * 16 - frameHeight;
					xOff = x;
					break;
				}
			}
			changeStatus(SMALL, true);
			live = true;
			startFrame = 0;
			maxFrame = 2;
			curFrame = 0;
			beforeStart = true;
			readyToRespawn = true;	
			velX = 0;
		}

	}

}