Ejemplo n.º 1
0
int main( int argc, char **argv )
{
	if( checkPrivileges( argc, argv ) == false )
	{
		return 0;
	}

	VeyonCore::setupApplicationParameters();

	QApplication app( argc, argv );

	VeyonCore core( &app, "Configurator" );

	ConfiguratorCore::silent = app.arguments().contains( "-quiet" ) ||
						app.arguments().contains( "-silent" ) ||
						app.arguments().contains( "-q" );

	if( checkWritableConfiguration() == false )
	{
		return -1;
	}

	// parse arguments
	QStringListIterator argIt( app.arguments() );
	argIt.next();

	while( argc > 1 && argIt.hasNext() )
	{
		const QString a = argIt.next().toLower();

		if( a == "-role" )
		{
			if( parseRole( argIt ) == false )
			{
				return -1;
			}
		}
		else if( a == "-createkeypair" )
		{
			return createKeyPair( argIt );
		}
		else if( a == "-importpublickey" || a == "-i" )
		{
			return importPublicKey( argIt );
		}
		else if( a == "-test" )
		{
			return ConfigurationTestController( app.arguments().mid( 2 ) ).run();
		}
	}

	// now create the main window
	auto mainWindow = new MainWindow;

	mainWindow->show();

	ilog( Info, "App.Exec" );

	return app.exec();
}
Ejemplo n.º 2
0
        bool parseQuery(const BSONObj &obj, QueryGeometry *out, bool *isNear, bool *intersect,
                        double *maxDistance) const {
            // pointA = { "type" : "Point", "coordinates": [ 40, 5 ] }
            // t.find({ "geo" : { "$intersect" : { "$geometry" : pointA} } })
            // t.find({ "geo" : { "$near" : { "$geometry" : pointA, $maxDistance : 20 }}})
            // where field.name is "geo"
            BSONElement e = obj.firstElement();
            if (!e.isABSONObj()) { return false; }

            BSONObj::MatchType matchType = static_cast<BSONObj::MatchType>(e.getGtLtOp());
            if (BSONObj::opGEO_INTERSECTS == matchType) {
                *intersect = true;
            } else if (BSONObj::opNEAR == matchType) {
                *isNear = true;
            } else {
                return false;
            }

            bool ret = false;
            BSONObjIterator argIt(e.embeddedObject());
            while (argIt.more()) {
                BSONElement e = argIt.next();
                if (mongoutils::str::equals(e.fieldName(), "$geometry")) {
                    if (e.isABSONObj()) {
                        BSONObj embeddedObj = e.embeddedObject();
                         if (out->parseFrom(embeddedObj)) {
                             uassert(16570, "near requires point, given " + embeddedObj.toString(),
                                     !(*isNear) || GeoParser::isPoint(embeddedObj));
                             ret = true;
                         }
                    }
                } else if (mongoutils::str::equals(e.fieldName(), "$maxDistance")) {
                    if (e.isNumber()) {
                        *maxDistance = e.Number();
                    }
                }
            }
            return ret;
        }