示例#1
0
文件: utils.cpp 项目: Rockbox/rockbox
/** @brief checks different Enviroment things. Ask if user wants to continue.
 *  @param permission if it should check for permission
 *  @return string with error messages if problems occurred, empty strings if none.
 */
QString Utils::checkEnvironment(bool permission)
{
    LOG_INFO() << "checking environment";
    QString text = "";

    // check permission
    if(permission)
    {
#if defined(Q_OS_WIN32)
        if(System::userPermissions() != System::ADMIN)
        {
            text += tr("<li>Permissions insufficient for bootloader "
                    "installation.\nAdministrator priviledges are necessary.</li>");
        }
#endif
    }

    // Check TargetId
    RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
    QString installed = rbinfo.target();
    if(!installed.isEmpty() && installed !=
       SystemInfo::value(SystemInfo::CurConfigureModel).toString())
    {
        text += tr("<li>Target mismatch detected.<br/>"
                "Installed target: %1<br/>Selected target: %2.</li>")
            .arg(SystemInfo::platformValue(installed, SystemInfo::CurPlatformName).toString(),
                 SystemInfo::value(SystemInfo::CurPlatformName).toString());
    }

    if(!text.isEmpty())
        return tr("Problem detected:") + "<ul>" + text + "</ul>";
    else
        return text;
}
示例#2
0
bool RbUtilQt::installAuto()
{
    QString file = RbSettings::value(RbSettings::ReleaseUrl).toString();
    file.replace("%MODEL%", RbSettings::value(RbSettings::CurBuildserverModel).toString());
    file.replace("%RELVERSION%", versmap.value("rel_rev"));
    buildInfo.open();
    QSettings info(buildInfo.fileName(), QSettings::IniFormat, this);
    buildInfo.close();

    // check installed Version and Target
    QString warning = check(false);
    if(!warning.isEmpty())
    {
        if(QMessageBox::warning(this, tr("Really continue?"), warning,
            QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
                == QMessageBox::Abort)
        {
            logger->addItem(tr("Aborted!"), LOGERROR);
            logger->setFinished();
            return false;
        }
    }

    // check version
    RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
    if(rbinfo.version() != "")
    {
        if(QMessageBox::question(this, tr("Installed Rockbox detected"),
           tr("Rockbox installation detected. Do you want to backup first?"),
           QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
        {
            logger->addItem(tr("Starting backup..."),LOGINFO);
            QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
                + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";

            //! create dir, if it doesnt exist
            QFileInfo backupFile(backupName);
            if(!QDir(backupFile.path()).exists())
            {
                QDir a;
                a.mkpath(backupFile.path());
            }

            //! create backup
            RbZip backup;
            connect(&backup,SIGNAL(zipProgress(int,int)),logger, SLOT(setProgress(int,int)));
            if(backup.createZip(backupName,
                RbSettings::value(RbSettings::Mountpoint).toString() + "/.rockbox") == Zip::Ok)
            {
                logger->addItem(tr("Backup successful"),LOGOK);
            }
            else
            {
                logger->addItem(tr("Backup failed!"),LOGERROR);
                logger->setFinished();
                return false;
            }
        }
    }
示例#3
0
osg::MatrixTransform * createModel( btDynamicsWorld * dynamicsWorld )
{
/*
 * BEGIN: Create physics object code.
 *  OSG CODE
 */
    osg::ref_ptr< osg::MatrixTransform > node;
	const std::string fileName( "glider.osg" );
    osg::ref_ptr< osg::Node > nodeDB = osgDB::readNodeFile( fileName );
	if( !nodeDB.valid() )
	{
		osg::notify( osg::FATAL ) << "Can't find \"" << fileName << "\". Make sure OSG_FILE_PATH includes the OSG sample data directory." << std::endl;
		exit( 0 );
	}

    if( ( node = dynamic_cast< osg::MatrixTransform * >( nodeDB.get() ) ) == NULL )
    {
        node = new osg::MatrixTransform;
        node->addChild( nodeDB.get() );
    }

    /*  osgBullet code */
    osgbDynamics::MotionState * motion = new osgbDynamics::MotionState;
    motion->setTransform( node.get() );
    btCollisionShape * collision = osgbCollision::btConvexTriMeshCollisionShapeFromOSG( node.get() );
    // Create an OSG representation of the Bullet shape and attach it.
    // This is mainly for debugging.
    osg::Node* debugNode = osgbCollision::osgNodeFromBtCollisionShape( collision );
    node->addChild( debugNode );

    // Set debug node state.
    osg::StateSet* state = debugNode->getOrCreateStateSet();
    osg::PolygonMode* pm = new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE );
    state->setAttributeAndModes( pm );
    osg::PolygonOffset* po = new osg::PolygonOffset( -1, -1 );
    state->setAttributeAndModes( po );
    state->setMode( GL_LIGHTING, osg::StateAttribute::OFF );

    /*  BULLET CODE */
    btTransform bodyTransform;
    bodyTransform.setIdentity();
    bodyTransform.setOrigin( btVector3( 0, 0, 5 ) );
    motion->setWorldTransform( bodyTransform );

    btScalar mass( 1.0 );
    btVector3 inertia;
    collision->calculateLocalInertia( mass, inertia );
    btRigidBody::btRigidBodyConstructionInfo rbinfo( mass, motion, collision, inertia );
    btRigidBody * body = new btRigidBody( rbinfo );
    body->setLinearVelocity( btVector3( -5, -1, 0 ) );
    body->setAngularVelocity( btVector3( 1, 0, 0 ) );
    dynamicsWorld->addRigidBody( body );
    
    // kick thing around from time to time.
    node->setUpdateCallback( new GliderUpdateCallback( body ) );
    
    return( node.release() );
}
示例#4
0
	bool Body::init(Physics *physics, Shape *shape, bool autodeactivation)
	{
		btTransform transform;
		transform.setIdentity();
		transform.setOrigin(btVector3(0, 0, 0));

		state = new btDefaultMotionState(transform);
		Vector3F inertia = shape->getInertia();

		btRigidBody::btRigidBodyConstructionInfo rbinfo(shape->getMass(), state,
			shape->getShape(), btVector3(inertia.x, inertia.y, inertia.z));
		body = new btRigidBody(rbinfo);
		//body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
		body->setUserPointer(this);

		physics->addBody(this);

		this->physics = physics;
		this->shape = shape;
		this->autodeactivation = autodeactivation;
		return true;
	}
示例#5
0
void createTarget( osg::Group * root,
                   btDynamicsWorld * dynamicsWorld )
{
    osg::MatrixTransform * target = createOffOriginOSGBox( osg::Vec3( 1, 1, 1 ) );
    root->addChild( target );

    /* osgBullet code */
    osgbDynamics::MotionState * motion = new osgbDynamics::MotionState();
    motion->setTransform( target );
    motion->setCenterOfMass( osg::Vec3( 1, 1, 1 ) );

    btCollisionShape* collision = osgbCollision::btBoxCollisionShapeFromOSG( target );

    btScalar mass( 1.0 );
    btVector3 inertia;
    collision->calculateLocalInertia( mass, inertia );
    btRigidBody::btRigidBodyConstructionInfo rbinfo( mass, motion, collision, inertia );
    btRigidBody* body = new btRigidBody( rbinfo );
    body->setLinearVelocity( btVector3( 1, 0, 0 ) );
    body->setAngularVelocity( btVector3( 1.5, 0, .25 ) );
    dynamicsWorld->addRigidBody( body );
}
示例#6
0
bool RbUtilQt::installAuto()
{
    QString file = SystemInfo::value(SystemInfo::ReleaseUrl).toString();
    file.replace("%MODEL%", SystemInfo::value(SystemInfo::CurBuildserverModel).toString());
    file.replace("%RELVERSION%", ServerInfo::value(ServerInfo::CurReleaseVersion).toString());

    // check installed Version and Target
    QString warning = Utils::checkEnvironment(false);
    if(!warning.isEmpty())
    {
        if(QMessageBox::warning(this, tr("Really continue?"), warning,
            QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort)
                == QMessageBox::Abort)
        {
            logger->addItem(tr("Aborted!"), LOGERROR);
            logger->setFinished();
            return false;
        }
    }

    // check version
    RockboxInfo rbinfo(RbSettings::value(RbSettings::Mountpoint).toString());
    if(rbinfo.version() != "")
    {
        if(QMessageBox::question(this, tr("Installed Rockbox detected"),
           tr("Rockbox installation detected. Do you want to backup first?"),
           QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
        {
            bool result;
            logger->addItem(tr("Starting backup..."),LOGINFO);
            QString backupName = RbSettings::value(RbSettings::Mountpoint).toString()
                + "/.backup/rockbox-backup-" + rbinfo.version() + ".zip";

            //! create dir, if it doesnt exist
            QFileInfo backupFile(backupName);
            if(!QDir(backupFile.path()).exists())
            {
                QDir a;
                a.mkpath(backupFile.path());
            }

            logger->addItem(tr("Beginning Backup..."),LOGINFO);
            QCoreApplication::processEvents();

            //! create backup
            ZipUtil zip(this);
            connect(&zip, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
            connect(&zip, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
            zip.open(backupName, QuaZip::mdCreate);
            QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
            QString folder = mp + "/.rockbox";
            result = zip.appendDirToArchive(folder, mp);
            zip.close();
            if(result)
            {
                logger->addItem(tr("Backup successful"),LOGOK);
            }
            else
            {
                logger->addItem(tr("Backup failed!"),LOGERROR);
                logger->setFinished();
                return false;
            }
        }
    }