/*! forks the current Process you can specify weather it will write a pidfile to /var/run/mydaemon.pid or not if you specify true (the default) QxtDaemon will also try to lock the pidfile. If it can't get a lock it will assume another daemon of the same name is already running and exit be aware that after calling this function all file descriptors are invalid. QFile will not detect the change, you have to explicitly close all files before forking. return true on success */ bool QxtDaemon::daemonize(bool pidfile) { #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) if (!logfile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) qFatal("cannot open logfile %s", qPrintable(logfile->fileName())); logfile->close(); if (pidfile) { QFile f("/var/run/" + m_name + ".pid"); if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) qFatal("cannot open pidfile \"/var/run/%s.pid\"", qPrintable(m_name)); if (lockf(f.handle(), F_TEST, 0) < 0) qFatal("can't get a lock on \"/var/run/%s.pid\". another instance is propably already running.", qPrintable(m_name)); f.close(); } if (!logfile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)) qFatal("cannot open logfile %s", qPrintable(logfile->fileName())); logfile->close(); int i; if (getppid() == 1) return true; /* already a daemon */ i = fork(); /* double fork.*/ if (i < 0) return false; /*fork error */ if (i > 0) exit(0); /*parent exits */ if (i < 0) return false; /*fork error */ if (i > 0) exit(0); /*parent exits */ /* child (daemon) continues */ setsid(); /* obtain a new process group */ for (i = getdtablesize();i >= 0;--i) close(i); /* close all descriptors */ #ifdef Q_OS_LINUX ::umask(027); /* some programmers don't understand security, so we set a sane default here */ #endif ::signal(SIGCHLD, SIG_IGN); /* ignore child */ ::signal(SIGTSTP, SIG_IGN); /* ignore tty signals */ ::signal(SIGTTOU, SIG_IGN); ::signal(SIGTTIN, SIG_IGN); ::signal(SIGHUP, QxtDaemon::signalHandler); /* catch hangup signal */ ::signal(SIGTERM, QxtDaemon::signalHandler); /* catch kill signal */ if (pidfile) { int lfp =::open(qPrintable("/var/run/" + m_name + ".pid"), O_RDWR | O_CREAT, 0640); if (lfp < 0) qFatal("cannot open pidfile \"/var/run/%s.pid\"", qPrintable(m_name)); if (lockf(lfp, F_TLOCK, 0) < 0) qFatal("can't get a lock on \"/var/run/%s.pid\". another instance is propably already running.", qPrintable(m_name)); QByteArray d = QByteArray::number(pid()); Q_UNUSED(::write(lfp, d.constData(), d.size())); } assert(logfile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)); qInstallMsgHandler(QxtDaemon::messageHandler); return true; #else return false; #endif }
void QAdoptedThread::run() { // this function should never be called qFatal("QAdoptedThread::run(): Internal error, this implementation should never be called."); }
void XmlRpcServer::registerSlot( QObject *receiver, const char *slot, QByteArray path ) { #ifdef DEBUG_XMLRPC qDebug() << this << "registerSlot():" << receiver << slot; #endif /* skip code first symbol 1 from SLOT macro (from qobject.cpp) */ ++slot; /* find QMetaMethod.. */ const QMetaObject *mo= receiver->metaObject(); /* we need buf in memory for const char (from qobject.cpp) */ QByteArray method= QMetaObject::normalizedSignature( slot ); const char *normalized= method.constData(); int slotId= mo->indexOfSlot( normalized ); if ( slotId == -1 ) { qCritical() << this << "registerSlot():" << receiver << normalized << "can't find slot"; qFatal( "programming error" ); } QMetaMethod m= receiver->metaObject()->method( slotId ); bool isDefferedResult= !qstrcmp( m.typeName(), "DeferredResult*" ); if ( qstrcmp( m.typeName(), "QVariant") && !isDefferedResult ) { qCritical() << this << "registerSlot():" << receiver << normalized << "rpc return type should be QVariant or DeferredResult*, but" << m.typeName(); qFatal( "programming error" ); } foreach( QByteArray c, m.parameterTypes() ) if ( c != "QVariant" ) { qCritical() << this << "registerSlot():" << receiver << normalized << "all parameters should be QVariant"; qFatal( "programming error" ); } /* ok, now lets make just function name from our SLOT */ Q_ASSERT( method.indexOf( '(') > 0 ); method.truncate( method.indexOf( '(') ); if ( path[0] != '/' ) path.prepend( '/' ); if ( path[path.size() - 1] != '/' ) path.append( '/' ); method.prepend( path ); /* check if allready exists */ if ( callbacks.contains( method) ) { qCritical() << this << "registerSlot():" << receiver << method << "allready registered, receiver" << callbacks[method]; qFatal( "programming error" ); } callbacks[method]= IsMethodDeffered( receiver, isDefferedResult ); Methods &methods= objectMethods[receiver]; if ( methods.isEmpty() ) { #ifdef DEBUG_XMLRPC qDebug() << this << "registerSlot(): connecting SIGNAL(destroyed()) of" << receiver; #endif connect( receiver, SIGNAL( destroyed ( QObject * )), this, SLOT( slotReceiverDestroed ( QObject * )) ); }
QDeclarativeAnchors::QDeclarativeAnchors(QObject *parent) : QObject(*new QDeclarativeAnchorsPrivate(0), parent) { qFatal("QDeclarativeAnchors::QDeclarativeAnchors(QObject*) called"); }
void initialize() override { OpenGLWindow::initialize(); //load shaders { QOpenGLShader vs(QOpenGLShader::Vertex); vs.compileSourceFile("TessellationTerrain/main.vs.glsl"); mProgram.addShader(&vs); QOpenGLShader tcs(QOpenGLShader::TessellationControl); tcs.compileSourceFile("TessellationTerrain/main.tcs.glsl"); mProgram.addShader(&tcs); QOpenGLShader tes(QOpenGLShader::TessellationEvaluation); tes.compileSourceFile("TessellationTerrain/main.tes.glsl"); mProgram.addShader(&tes); QOpenGLShader fs(QOpenGLShader::Fragment); fs.compileSourceFile("TessellationTerrain/main.fs.glsl"); mProgram.addShader(&fs); if (!mProgram.link()) qFatal("Error linking shaders"); } //grab uniform locations { mUniforms.mvMatrix = mProgram.uniformLocation("mvMatrix"); mUniforms.mvpMatrix = mProgram.uniformLocation("mvpMatrix"); mUniforms.projMatrix = mProgram.uniformLocation("projMatrix"); mUniforms.dmapDepth = mProgram.uniformLocation("dmapDepth"); } mVao.bind(); glPatchParameteri(GL_PATCH_VERTICES, 4); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //build displacment map { QVector<GLubyte> displacmentMap; displacmentMap.reserve(mSize*mSize); std::srand(35456); for (int i=0; i<mSize*mSize; i++) displacmentMap.append(randInt(0, 255)); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexStorage2D(GL_TEXTURE_2D, 1, GL_R8, mSize, mSize); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mSize, mSize, GL_R, GL_UNSIGNED_BYTE, &displacmentMap[0]); } //load terrain texture { glActiveTexture(GL_TEXTURE1); mTerrainTexture = QSharedPointer<QOpenGLTexture>(new QOpenGLTexture(QImage("./Common/dirt.png").mirrored())); mTerrainTexture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); mTerrainTexture->setMagnificationFilter(QOpenGLTexture::Linear); } }
//**************************************************************************** void Q_onAssert(char_t const * const module, int loc) { QS_ASSERTION(module, loc, 10000U); // send assertion info to the QS trace qFatal("Assertion failed in module %s, location %d", module, loc); }
QString QFont::lastResortFont() const { qFatal("QFont::lastResortFont: Cannot find any reasonable font"); // Shut compiler up return QString(); }
syncManagerType::syncManagerType(QDomElement element, bool verbose) { QString attributeStr; verb = verbose; // Parse value for SM type if (element.text().compare("MBoxOut") == 0) { if (verb) qDebug()<<"--SM type: MBoxOut"; smType = mailboxOut; } else if (element.text().compare("MBoxIn") == 0) { if (verb) qDebug()<<"--SM type: MBoxIn"; smType = mailboxIn; } else if (element.text().compare("Outputs") == 0) { if (verb) qDebug()<<"--SM type: Outputs"; smType = processDataOut; } else if (element.text().compare("Inputs") == 0) { if (verb) qDebug()<<"--SM type: Inputs"; smType = processDataIn; } else { if (verb) qDebug()<<"--SM type: Unused"; smType = unused; phyStartAddr = 0; length = 0; controlRegister = 0; enable = false; virtualSM = false; opOnly = false; return; } attributeStr.clear(); attributeStr = element.attribute("StartAddress"); if (!attributeStr.isEmpty()) { if (verb) qDebug()<<"--Found start address with value:"<<attributeStr; // since it would appear the default hex encoding is #x0000 then we need to catch this our selves if ((attributeStr.at(0) == '#') && (attributeStr.at(1) == 'x')) phyStartAddr = attributeStr.remove(0,2).toInt(0,16); else phyStartAddr = attributeStr.toInt(0,0); } else qFatal("No start address found for sync manager"); attributeStr.clear(); attributeStr = element.attribute("ControlByte"); if (!attributeStr.isEmpty()) { if (verb) qDebug()<<"--Found ControlByte with value:"<<attributeStr; // since it would appear the default hex encoding is #x0000 then we need to catch this our selves if ((attributeStr.at(0) == '#') && (attributeStr.at(1) == 'x')) controlRegister = attributeStr.remove(0,2).toInt(0,16); else controlRegister = attributeStr.toInt(0,0); } else controlRegister = 0; attributeStr.clear(); attributeStr = element.attribute("DefaultSize"); if (!attributeStr.isEmpty()) { if (verb) qDebug()<<"--Found DefaultSize with value:"<<attributeStr; // since it would appear the default hex encoding is #x0000 then we need to catch this our selves if ((attributeStr.at(0) == '#') && (attributeStr.at(1) == 'x')) length = attributeStr.remove(0,2).toInt(0,16); else length = attributeStr.toInt(0,0); } else length = 0; attributeStr.clear(); attributeStr = element.attribute("Enable"); if (!attributeStr.isEmpty()) { if (verb) qDebug()<<"--Found Enable attribute with value:"<<attributeStr; if ((attributeStr.at(0) == '#') && (attributeStr.at(1) == 'x')) enable = attributeStr.remove(0,2).toInt(0,16) != 0; else enable = attributeStr.toInt(0,0) != 0; } else enable = false; attributeStr.clear(); attributeStr = element.attribute("Virtual"); if (!attributeStr.isEmpty()) { if (verb) qDebug()<<"--Found Virtual attribute with value:"<<attributeStr; if ((attributeStr.at(0) == '#') && (attributeStr.at(1) == 'x')) virtualSM = attributeStr.remove(0,2).toInt(0,16) != 0; else virtualSM = attributeStr.toInt(0,0) != 0; } else virtualSM = false; attributeStr.clear(); attributeStr = element.attribute("OpOnly"); if (!attributeStr.isEmpty()) { if (verb) qDebug()<<"--Found OpOnly attribute with value:"<<attributeStr; opOnly = (attributeStr.remove(0,2).toInt(0,16) != 0); } else opOnly = false; }
void Platform::Assert(const char *c, const char *file, int line) { qFatal("Assertion [%s] failed at %s %d\n", c, file, line); }
Q_DECL_EXPORT #endif int main(int argc, char *argv[]) { #if defined(Q_WS_X11) #if QT_VERSION >= 0x040800 QApplication::setAttribute(Qt::AA_X11InitThreads, true); #else XInitThreads(); QApplication::setAttribute(static_cast<Qt::ApplicationAttribute>(10), true); #endif #endif QApplication *application; QDeclarativeView *view; #ifdef HARMATTAN_BOOSTER application = MDeclarativeCache::qApplication(argc, argv); view = MDeclarativeCache::qDeclarativeView(); #else qWarning() << Q_FUNC_INFO << "Warning! Running without booster. This may be a bit slower."; QApplication stackApp(argc, argv); QmlApplicationViewer stackView; application = &stackApp; view = &stackView; stackView.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); #endif application->setQuitOnLastWindowClosed(true); // FIXME uncommenting this will make UI not loaded // QMozContext::GetInstance(); QString path; QString urlstring; QString qmlstring; #ifdef __arm__ bool isFullscreen = true; #else bool isFullscreen = false; #endif #if !defined(Q_WS_MAEMO_5) bool glwidget = true; #else bool glwidget = false; #endif QStringList arguments = application->arguments(); for (int i = 0; i < arguments.count(); ++i) { QString parameter = arguments.at(i); if (parameter == "-path") { if (i + 1 >= arguments.count()) qFatal("-path requires an argument"); path = arguments.at(i + 1); i++; } else if (parameter == "-url") { if (i + 1 >= arguments.count()) qFatal("-url requires an argument"); urlstring = arguments.at(i + 1); i++; } else if (parameter == "-qml") { if (i + 1 >= arguments.count()) qFatal("-qml requires an argument"); qmlstring = arguments.at(i + 1); i++; } else if (parameter == "-fullscreen") { isFullscreen = true; } else if (parameter == "-no-glwidget") { glwidget = false; } else if (parameter == "-glwidget") { glwidget = true; } else if (parameter == "-help") { qDebug() << "EMail application"; qDebug() << "-fullscreen - show QML fullscreen"; qDebug() << "-path - path to cd to before launching -url"; qDebug() << "-qml - file to launch (default: main.qml inside -path)"; qDebug() << "-url - url to load"; qDebug() << "-no-glwidget - Don't use QGLWidget viewport"; exit(0); } } if (!path.isEmpty()) QDir::setCurrent(path); qmlRegisterType<QMozContext>("QtMozilla", 1, 0, "QMozContext"); qmlRegisterType<QGraphicsMozView>("QtMozilla", 1, 0, "QGraphicsMozView"); qmlRegisterType<QDeclarativeMozView>("QtMozilla", 1, 0, "QDeclarativeMozView"); QUrl qml; if (qmlstring.isEmpty()) #if defined(__arm__) && !defined(Q_WS_MAEMO_5) qml = QUrl("qrc:/qml/main_meego.qml"); #else qml = QUrl("qrc:/qml/main.qml"); #endif else
QVariant Dot3Protocol::fieldData(int index, FieldAttrib attrib, int streamIndex) const { switch (index) { case dot3_length: switch(attrib) { case FieldName: return QString("Length"); case FieldValue: { quint16 len = data.is_override_length() ? data.length() : protocolFramePayloadSize(streamIndex); return len; } case FieldTextValue: { quint16 len = data.is_override_length() ? data.length() : protocolFramePayloadSize(streamIndex); return QString("%1").arg(len); } case FieldFrameValue: { quint16 len = data.is_override_length() ? data.length() : protocolFramePayloadSize(streamIndex); QByteArray fv; fv.resize(2); qToBigEndian(len, (uchar*) fv.data()); return fv; } case FieldBitSize: return 16; default: break; } break; // Meta fields case dot3_is_override_length: { switch(attrib) { case FieldValue: return data.is_override_length(); default: break; } break; } default: qFatal("%s: unimplemented case %d in switch", __PRETTY_FUNCTION__, index); break; } return AbstractProtocol::fieldData(index, attrib, streamIndex); }
Scanner::Token Scanner::nextToken() { Token tok = NoToken; // remove whitespace while (m_pos < m_length && m_chars[m_pos] == ' ') { ++m_pos; } m_token_start = m_pos; while (m_pos < m_length) { const QChar &c = m_chars[m_pos]; if (tok == NoToken) { switch (c.toLatin1()) { case '*': tok = StarToken; break; case '&': tok = AmpersandToken; break; case '<': tok = LessThanToken; break; case '>': tok = GreaterThanToken; break; case ',': tok = CommaToken; break; case '(': tok = OpenParenToken; break; case ')': tok = CloseParenToken; break; case '[': tok = SquareBegin; break; case ']' : tok = SquareEnd; break; case ':': tok = ColonToken; Q_ASSERT(m_pos + 1 < m_length); ++m_pos; break; default: if (c.isLetterOrNumber() || c == '_') tok = Identifier; else qFatal("Unrecognized character in lexer: %c", c.toLatin1()); break; } } if (tok <= GreaterThanToken) { ++m_pos; break; } if (tok == Identifier) { if (c.isLetterOrNumber() || c == '_') ++m_pos; else break; } } if (tok == Identifier && m_pos - m_token_start == 5) { if (m_chars[m_token_start] == 'c' && m_chars[m_token_start + 1] == 'o' && m_chars[m_token_start + 2] == 'n' && m_chars[m_token_start + 3] == 's' && m_chars[m_token_start + 4] == 't') tok = ConstToken; } return tok; }
QObject* Plugin::component(ComponentType componentType, QObject*) { qFatal("Plugin '%s' was asked to create a component of type %d", qPrintable(uniqueId()), componentType); return 0; // -Wall -Werror }
bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) { int id = arg.userType(); if (id == QVariant::Invalid) { qWarning("QDBusMarshaller: cannot add an invalid QVariant"); error(); return false; } // intercept QDBusArgument parameters here if (id == qMetaTypeId<QDBusArgument>()) { QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg); QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument); if (!d->message) return false; // can't append this one... QDBusDemarshaller demarshaller; demarshaller.message = q_dbus_message_ref(d->message); if (d->direction == Demarshalling) { // it's demarshalling; just copy demarshaller.iterator = static_cast<QDBusDemarshaller *>(d)->iterator; } else { // it's marshalling; start over if (!q_dbus_message_iter_init(demarshaller.message, &demarshaller.iterator)) return false; // error! } return appendCrossMarshalling(&demarshaller); } const char *signature = QDBusMetaType::typeToSignature( QVariant::Type(id) ); if (!signature) { qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. " "Use qDBusRegisterMetaType to register it", QVariant::typeToName( QVariant::Type(id) ), id); error(); return false; } switch (*signature) { #ifdef __OPTIMIZE__ case DBUS_TYPE_BYTE: case DBUS_TYPE_BOOLEAN: case DBUS_TYPE_INT16: case DBUS_TYPE_UINT16: case DBUS_TYPE_INT32: case DBUS_TYPE_UINT32: case DBUS_TYPE_INT64: case DBUS_TYPE_UINT64: case DBUS_TYPE_DOUBLE: qIterAppend(&iterator, ba, *signature, arg.constData()); return true; case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: case DBUS_TYPE_SIGNATURE: { const QByteArray data = reinterpret_cast<const QString *>(arg.constData())->toUtf8(); const char *rawData = data.constData(); qIterAppend(&iterator, ba, *signature, &rawData); return true; } #else case DBUS_TYPE_BYTE: append( qvariant_cast<uchar>(arg) ); return true; case DBUS_TYPE_BOOLEAN: append( arg.toBool() ); return true; case DBUS_TYPE_INT16: append( qvariant_cast<short>(arg) ); return true; case DBUS_TYPE_UINT16: append( qvariant_cast<ushort>(arg) ); return true; case DBUS_TYPE_INT32: append( static_cast<dbus_int32_t>(arg.toInt()) ); return true; case DBUS_TYPE_UINT32: append( static_cast<dbus_uint32_t>(arg.toUInt()) ); return true; case DBUS_TYPE_INT64: append( arg.toLongLong() ); return true; case DBUS_TYPE_UINT64: append( arg.toULongLong() ); return true; case DBUS_TYPE_DOUBLE: append( arg.toDouble() ); return true; case DBUS_TYPE_STRING: append( arg.toString() ); return true; case DBUS_TYPE_OBJECT_PATH: append( qvariant_cast<QDBusObjectPath>(arg) ); return true; case DBUS_TYPE_SIGNATURE: append( qvariant_cast<QDBusSignature>(arg) ); return true; #endif // compound types: case DBUS_TYPE_VARIANT: // nested QVariant return append( qvariant_cast<QDBusVariant>(arg) ); case DBUS_TYPE_ARRAY: // could be many things // find out what kind of array it is switch (arg.type()) { case QVariant::StringList: append( arg.toStringList() ); return true; case QVariant::ByteArray: append( arg.toByteArray() ); return true; default: ; // fall through } // fall through case DBUS_TYPE_STRUCT: case DBUS_STRUCT_BEGIN_CHAR: return appendRegisteredType( arg ); case DBUS_TYPE_DICT_ENTRY: case DBUS_DICT_ENTRY_BEGIN_CHAR: qFatal("QDBusMarshaller::appendVariantInternal got a DICT_ENTRY!"); return false; default: qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'", signature); return false; } return true; }
void MScore::init() { if (!QMetaType::registerConverter<Spatium, double>(&Spatium::toDouble)) qFatal("registerConverter Spatium::toDouble failed"); if (!QMetaType::registerConverter<double, Spatium>(&doubleToSpatium)) qFatal("registerConverter douobleToSpatium failed"); if (!QMetaType::registerConverter<int, TextStyleType>(&intToTextStyleType)) qFatal("registerConverter intToTextStyleType failed"); #ifdef SCRIPT_INTERFACE qRegisterMetaType<Element::Type> ("ElementType"); qRegisterMetaType<Note::ValueType> ("ValueType"); qRegisterMetaType<Direction::E>("Direction"); qRegisterMetaType<MScore::DirectionH>("DirectionH"); qRegisterMetaType<Element::Placement>("Placement"); qRegisterMetaType<Spanner::Anchor> ("Anchor"); qRegisterMetaType<NoteHead::Group> ("NoteHeadGroup"); qRegisterMetaType<NoteHead::Type>("NoteHeadType"); qRegisterMetaType<Segment::Type>("SegmentType"); qRegisterMetaType<FiguredBassItem::Modifier>("Modifier"); qRegisterMetaType<FiguredBassItem::Parenthesis>("Parenthesis"); qRegisterMetaType<FiguredBassItem::ContLine>("ContLine"); qRegisterMetaType<Volta::Type>("VoltaType"); qRegisterMetaType<Ottava::Type>("OttavaType"); qRegisterMetaType<Trill::Type>("TrillType"); qRegisterMetaType<Dynamic::Range>("DynamicRange"); qRegisterMetaType<Jump::Type>("JumpType"); qRegisterMetaType<Marker::Type>("MarkerType"); qRegisterMetaType<Beam::Mode>("BeamMode"); qRegisterMetaType<HairpinType>("HairpinType"); qRegisterMetaType<Lyrics::Syllabic>("Syllabic"); qRegisterMetaType<LayoutBreak::Type>("LayoutBreakType"); qRegisterMetaType<Glissando::Type>("GlissandoType"); //classed enumerations qRegisterMetaType<MSQE_TextStyleType::E>("TextStyleType"); qRegisterMetaType<MSQE_BarLineType::E>("BarLineType"); #endif qRegisterMetaType<Fraction>("Fraction"); // DPMM = DPI / INCH; // dots/mm #ifdef Q_OS_WIN QDir dir(QCoreApplication::applicationDirPath() + QString("/../" INSTALL_NAME)); _globalShare = dir.absolutePath() + "/"; #elif defined(Q_OS_IOS) { extern QString resourcePath(); _globalShare = resourcePath(); } #elif defined(Q_OS_MAC) QDir dir(QCoreApplication::applicationDirPath() + QString("/../Resources")); _globalShare = dir.absolutePath() + "/"; #else // Try relative path (needed for portable AppImage and non-standard installations) QDir dir(QCoreApplication::applicationDirPath() + QString("/../share/" INSTALL_NAME)); if (dir.exists()) _globalShare = dir.absolutePath() + "/"; else // Fall back to default location (e.g. if binary has moved relative to share) _globalShare = QString( INSTPREFIX "/share/" INSTALL_NAME); #endif selectColor[0].setNamedColor("#1259d0"); //blue selectColor[1].setNamedColor("#009234"); //green selectColor[2].setNamedColor("#c04400"); //orange selectColor[3].setNamedColor("#70167a"); //purple defaultColor = Qt::black; dropColor = QColor("#1778db"); defaultPlayDuration = 300; // ms warnPitchRange = true; playRepeats = true; panPlayback = true; lastError = ""; layoutBreakColor = QColor("#5999db"); frameMarginColor = QColor("#5999db"); bgColor.setNamedColor("#dddddd"); _defaultStyle = new MStyle(); Ms::initStyle(_defaultStyle); _defaultStyleForParts = 0; _baseStyle = new MStyle(*_defaultStyle); // // load internal fonts // // // do not load application specific fonts // for MAC, they are in Resources/fonts // #if !defined(Q_OS_MAC) && !defined(Q_OS_IOS) static const char* fonts[] = { ":/fonts/musejazz/MuseJazzText.ttf", ":/fonts/FreeSans.ttf", ":/fonts/FreeSerif.ttf", ":/fonts/FreeSerifBold.ttf", ":/fonts/FreeSerifItalic.ttf", ":/fonts/FreeSerifBoldItalic.ttf", ":/fonts/mscoreTab.ttf", ":/fonts/mscore-BC.ttf", ":/fonts/bravura/BravuraText.otf", ":/fonts/gootville/GootvilleText.otf", ":/fonts/mscore/MScoreText.ttf", }; for (unsigned i = 0; i < sizeof(fonts)/sizeof(*fonts); ++i) { QString s(fonts[i]); if (-1 == QFontDatabase::addApplicationFont(s)) { if (!MScore::testMode) qDebug("Mscore: fatal error: cannot load internal font <%s>", qPrintable(s)); if (!MScore::debugMode && !MScore::testMode) exit(-1); } } #endif initScoreFonts(); StaffType::initStaffTypes(); initDrumset(); FiguredBass::readConfigFile(0); #ifdef DEBUG_SHAPES testShapes(); #endif }
/** \internal */ bool GetOpt::parse( bool untilFirstSwitchOnly ) { // qDebug( "parse(%s)", args.join( QString( "," ) ).toLocal8Bit().constData() ); // push all arguments as we got them on a stack // more pushes might following when parsing condensed arguments // like --key=value. QStack<QString> stack; if (!args.empty()) { QStringList::const_iterator it = args.end(); while ( it != args.begin() ) { --it; stack.push( *it ); } } const OptionConstIterator obegin = options.begin(); const OptionConstIterator oend = options.end(); enum { StartState, ExpectingState, OptionalState } state = StartState; Option currOpt; enum TokenType { LongOpt, ShortOpt, Arg, End } t, currType = End; bool extraLoop = true; // we'll do an extra round. fake an End argument while ( !stack.isEmpty() || extraLoop ) { QString a; QString origA; // identify argument type if ( !stack.isEmpty() ) { a = stack.pop(); currArg++; origA = a; // qDebug( "popped %s", a.toLocal8Bit().constData() ); if ( a.startsWith( QString::fromLatin1( "--" ) ) ) { // recognized long option a = a.mid( 2 ); if ( a.isEmpty() ) { qWarning( "'--' feature not supported, yet" ); exit( 2 ); } t = LongOpt; // split key=value style arguments int equal = a.indexOf( '=' ); if ( equal >= 0 ) { stack.push( a.mid( equal + 1 ) ); currArg--; a = a.left( equal ); } } else if ( a.length() == 1 ) { t = Arg; } else if ( a[0] == '-' ) { #if 0 // compat mode for -long style options if ( a.length() == 2 ) { t = ShortOpt; a = a[1]; } else { a = a.mid( 1 ); t = LongOpt; // split key=value style arguments int equal = a.find( '=' ); if ( equal >= 0 ) { stack.push( a.mid( equal + 1 ) ); currArg--; a = a.left( equal ); } } #else // short option t = ShortOpt; // followed by an argument ? push it for later processing. if ( a.length() > 2 ) { stack.push( a.mid( 2 ) ); currArg--; } a = a[1]; #endif } else { t = Arg; } } else { // faked closing argument t = End; } // look up among known list of options Option opt; if ( t != End ) { OptionConstIterator oit = obegin; while ( oit != oend ) { const Option &o = *oit; if ( ( t == LongOpt && a == o.lname ) || // ### check state ( t == ShortOpt && a[0].unicode() == o.sname ) ) { opt = o; break; } ++oit; } if ( t == LongOpt && opt.type == OUnknown ) { if ( currOpt.type != OVarLen ) { qWarning( "Unknown option --%s", a.toLocal8Bit().constData() ); return false; } else { // VarLength options support arguments starting with '-' t = Arg; } } else if ( t == ShortOpt && opt.type == OUnknown ) { if ( currOpt.type != OVarLen ) { qWarning( "Unknown option -%c", a[0].unicode() ); return false; } else { // VarLength options support arguments starting with '-' t = Arg; } } } else { opt = Option( OEnd ); } // interpret result switch ( state ) { case StartState: if ( opt.type == OSwitch ) { setSwitch( opt ); setOptions.insert( opt.lname, 1 ); setOptions.insert( QString( QChar( opt.sname ) ), 1 ); } else if ( opt.type == OArg1 || opt.type == ORepeat ) { state = ExpectingState; currOpt = opt; currType = t; setOptions.insert( opt.lname, 1 ); setOptions.insert( QString( QChar( opt.sname ) ), 1 ); } else if ( opt.type == OOpt || opt.type == OVarLen ) { state = OptionalState; currOpt = opt; currType = t; setOptions.insert( opt.lname, 1 ); setOptions.insert( QString( QChar( opt.sname ) ), 1 ); } else if ( opt.type == OEnd ) { // we're done } else if ( opt.type == OUnknown && t == Arg ) { if ( numReqArgs > 0 ) { if ( reqArg.stringValue->isNull() ) { // ### *reqArg.stringValue = a; } else { qWarning( "Too many arguments" ); return false; } } else if ( numOptArgs > 0 ) { if ( optArg.stringValue->isNull() ) { // ### *optArg.stringValue = a; } else { qWarning( "Too many arguments" ); return false; } } } else { qFatal( "unhandled StartState case %d", opt.type ); } break; case ExpectingState: if ( t == Arg ) { if ( currOpt.type == OArg1 ) { *currOpt.stringValue = a; state = StartState; } else if ( currOpt.type == ORepeat ) { currOpt.listValue->append( a ); state = StartState; } else { abort(); } } else { QString n = currType == LongOpt ? currOpt.lname : QString( QChar( currOpt.sname ) ); qWarning( "Expected an argument after '%s' option", n.toLocal8Bit().constData() ); return false; } break; case OptionalState: if ( t == Arg ) { if ( currOpt.type == OOpt ) { *currOpt.stringValue = a; state = StartState; } else if ( currOpt.type == OVarLen ) { currOpt.listValue->append( origA ); // remain in this state } else { abort(); } } else { // optional argument not specified if ( currOpt.type == OOpt ) *currOpt.stringValue = currOpt.def; if ( t != End ) { // re-evaluate current argument stack.push( origA ); currArg--; } state = StartState; } break; } if ( untilFirstSwitchOnly && opt.type == OSwitch ) return true; // are we in the extra loop ? if so, flag the final end if ( t == End ) extraLoop = false; } if ( numReqArgs > 0 && reqArg.stringValue->isNull() ) { qWarning( "Lacking required argument" ); return false; } return true; }
Worker::Worker(RoboCompJointMotor::JointMotorPrx jointmotorprx, QObject *parent) : QObject(parent) { jointmotor = jointmotorprx; //mutex = new QMutex(); //setupUi(this); //show(); // try // { // params = jointmotor->getAllMotorParams(); // if(params.size() < 4) // qFatal("Error num motor: required 4 obtained: "+params.size()); // } // catch(Ice::Exception e) // { // qFatal("Error talking to jointMotor::getting params"); // } // // r_vmax.resize(4); // //Creamos el vector de rampas // for(int i=0;i<4;i++) // rampa.append(1); // //Calcula r_vmax para cada motor // for(int i=0;i<4;i++) // { // params[i].maxVelocity = 2.5; // qDebug()<<"velocidad maxima"<<params[i].maxVelocity; // r_vmax[i] = pow(params[i].maxVelocity,2)/(rampa.at(i)*2); // } // move = false; // vLimites.resize(4); // pDistances.resize(4); // tiempo = 0.f; // tcambio1.resize(4); // tcambio2.resize(4); // goals.resize(4); // poseEstimada.resize(4); // poseInicial.resize(4); // // for(uint i=0;i<params.size();i++) // { // RoboCompJointMotor::MotorGoalPosition goal; // // goal.position = -2.f; // goal.name = params[i].name; // // goal.maxSpeed = 6.f; // // // goals[i] = goal; // } // // qDebug()<<"constructor"; connect(&timer, SIGNAL(timeout()), this, SLOT(compute())); timer.start(BASIC_PERIOD); /**NUEVO*/ try { params = jointmotor->getAllMotorParams(); if(params.size() < 10) qFatal("Error num motor: required 10 obtained: "+params.size()); } catch(Ice::Exception e) { qFatal("Error talking to jointMotor::getting params"); } right.resize(5); left.resize(5); both.resize(10); RoboCompJointMotor::MotorGoalPosition aux; aux.maxSpeed = 0.75; for(int i=0;i<5;i++) { right[i] = aux; left[i] = aux; both[i] = aux; both[i+5] = aux; } both[0].name = right[0].name = "r1"; both[1].name = right[1].name = "r2"; both[2].name = right[2].name = "r3"; both[3].name = right[3].name = "r4"; both[4].name = right[4].name = "r5"; both[5].name = left[0].name = "l1"; both[6].name = left[1].name = "l2"; both[7].name = left[2].name = "l3"; both[8].name = left[3].name = "l4"; both[9].name = left[4].name = "l5"; }
void SessionFactory::CreateSession(Node *node, const Id &session_id, SessionType type, AuthFactory::AuthType auth_type, const QSharedPointer<KeyShare> &public_keys) { CreateRound cr; switch(type) { case NULL_ROUND: cr = &TCreateRound<NullRound>; break; case SHUFFLE: cr = &TCreateRound<ShuffleRound>; break; case BULK: cr = &TCreateRound<BulkRound>; break; case REPEATING_BULK: cr = &TCreateRound<RepeatingBulkRound>; break; case CSBULK: cr = &TCreateBulkRound<CSBulkRound, NeffKeyShuffleRound>; break; case NEFF_SHUFFLE: cr = &TCreateRound<NeffShuffleRound>; case BLOG_DROP_REACTIVE: cr = TCreateBlogDropRound<Parameters::ParameterType_CppECHashingProduction, NeffShuffleRound, false>; break; case BLOG_DROP_PROACTIVE: cr = TCreateBlogDropRound<Parameters::ParameterType_CppECHashingProduction, NeffShuffleRound, true>; break; default: qFatal("Invalid session type"); } QSharedPointer<IAuthenticate> authe(AuthFactory::CreateAuthenticate( node, auth_type, public_keys)); Session *session = new Session(node->GetGroupHolder(), authe, session_id, node->GetNetwork(), cr); QObject::connect(node->GetOverlay().data(), SIGNAL(Disconnecting()), session, SLOT(CallStop())); QSharedPointer<Session> psession(session); session->SetSharedPointer(psession); node->GetSessionManager().AddSession(psession); psession->SetSink(node->GetSink().data()); if(node->GetPrivateIdentity().GetLocalId() == node->GetGroupHolder()->GetGroup().GetLeader()) { QSharedPointer<IAuthenticator> autho(AuthFactory::CreateAuthenticator( node, auth_type, public_keys)); QSharedPointer<SessionLeader> sl(new SessionLeader( node->GetGroupHolder()->GetGroup(), node->GetPrivateIdentity(), node->GetNetwork(), psession, autho)); node->GetSessionManager().AddSessionLeader(sl); sl->Start(); } else { psession->Start(); } }
bool testPlayerScript(QString path, int player, int difficulty) { QScriptEngine *engine = new QScriptEngine(); QFile input(path); input.open(QIODevice::ReadOnly); QString source(QString::fromUtf8(input.readAll())); input.close(); // Special functions engine->globalObject().setProperty("setTimer", engine->newFunction(js_setTimer)); engine->globalObject().setProperty("queue", engine->newFunction(js_queue)); engine->globalObject().setProperty("removeTimer", engine->newFunction(js_removeTimer)); engine->globalObject().setProperty("include", engine->newFunction(js_include)); engine->globalObject().setProperty("bind", engine->newFunction(js_bind)); // Special global variables engine->globalObject().setProperty("version", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("selectedPlayer", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("gameTime", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("difficulty", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("mapName", "TEST", QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("baseType", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("alliancesType", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("powerType", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("maxPlayers", CUR_PLAYERS, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("scavengers", true, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("mapWidth", 80, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("mapHeight", 80, QScriptValue::ReadOnly | QScriptValue::Undeletable); // Most special global engine->globalObject().setProperty("me", player, QScriptValue::ReadOnly | QScriptValue::Undeletable); // Register functions to the script engine here engine->globalObject().setProperty("_", engine->newFunction(js_translate)); engine->globalObject().setProperty("label", engine->newFunction(js_label)); engine->globalObject().setProperty("enumLabels", engine->newFunction(js_enumLabels)); engine->globalObject().setProperty("enumGateways", engine->newFunction(js_enumGateways)); // horrible hacks follow -- do not rely on these being present! engine->globalObject().setProperty("hackNetOff", engine->newFunction(js_hackNetOff)); engine->globalObject().setProperty("hackNetOn", engine->newFunction(js_hackNetOn)); engine->globalObject().setProperty("objFromId", engine->newFunction(js_objFromId)); // General functions -- geared for use in AI scripts engine->globalObject().setProperty("debug", engine->newFunction(js_debug)); engine->globalObject().setProperty("console", engine->newFunction(js_console)); engine->globalObject().setProperty("structureIdle", engine->newFunction(js_structureIdle)); engine->globalObject().setProperty("enumStruct", engine->newFunction(js_enumStruct)); engine->globalObject().setProperty("enumStructOffWorld", engine->newFunction(js_enumStructOffWorld)); engine->globalObject().setProperty("enumDroid", engine->newFunction(js_enumDroid)); engine->globalObject().setProperty("enumGroup", engine->newFunction(js_enumGroup)); engine->globalObject().setProperty("enumFeature", engine->newFunction(js_enumFeature)); engine->globalObject().setProperty("enumBlips", engine->newFunction(js_enumBlips)); engine->globalObject().setProperty("enumResearch", engine->newFunction(js_enumResearch)); engine->globalObject().setProperty("getResearch", engine->newFunction(js_getResearch)); engine->globalObject().setProperty("pursueResearch", engine->newFunction(js_pursueResearch)); engine->globalObject().setProperty("distBetweenTwoPoints", engine->newFunction(js_distBetweenTwoPoints)); engine->globalObject().setProperty("newGroup", engine->newFunction(js_newGroup)); engine->globalObject().setProperty("groupAddArea", engine->newFunction(js_groupAddArea)); engine->globalObject().setProperty("groupAddDroid", engine->newFunction(js_groupAddDroid)); engine->globalObject().setProperty("groupSize", engine->newFunction(js_groupSize)); engine->globalObject().setProperty("orderDroidLoc", engine->newFunction(js_orderDroidLoc)); engine->globalObject().setProperty("playerPower", engine->newFunction(js_playerPower)); engine->globalObject().setProperty("isStructureAvailable", engine->newFunction(js_isStructureAvailable)); engine->globalObject().setProperty("pickStructLocation", engine->newFunction(js_pickStructLocation)); engine->globalObject().setProperty("droidCanReach", engine->newFunction(js_droidCanReach)); engine->globalObject().setProperty("orderDroidStatsLoc", engine->newFunction(js_orderDroidBuild)); // deprecated engine->globalObject().setProperty("orderDroidBuild", engine->newFunction(js_orderDroidBuild)); engine->globalObject().setProperty("orderDroidObj", engine->newFunction(js_orderDroidObj)); engine->globalObject().setProperty("orderDroid", engine->newFunction(js_orderDroid)); engine->globalObject().setProperty("buildDroid", engine->newFunction(js_buildDroid)); engine->globalObject().setProperty("addDroid", engine->newFunction(js_addDroid)); engine->globalObject().setProperty("addFeature", engine->newFunction(js_addFeature)); engine->globalObject().setProperty("componentAvailable", engine->newFunction(js_componentAvailable)); engine->globalObject().setProperty("isVTOL", engine->newFunction(js_isVTOL)); engine->globalObject().setProperty("safeDest", engine->newFunction(js_safeDest)); engine->globalObject().setProperty("activateStructure", engine->newFunction(js_activateStructure)); engine->globalObject().setProperty("chat", engine->newFunction(js_chat)); // Functions that operate on the current player only engine->globalObject().setProperty("centreView", engine->newFunction(js_centreView)); engine->globalObject().setProperty("playSound", engine->newFunction(js_playSound)); engine->globalObject().setProperty("gameOverMessage", engine->newFunction(js_gameOverMessage)); // Global state manipulation -- not for use with skirmish AI (unless you want it to cheat, obviously) engine->globalObject().setProperty("setStructureLimits", engine->newFunction(js_setStructureLimits)); engine->globalObject().setProperty("applyLimitSet", engine->newFunction(js_applyLimitSet)); engine->globalObject().setProperty("setMissionTime", engine->newFunction(js_setMissionTime)); engine->globalObject().setProperty("setReinforcementTime", engine->newFunction(js_setReinforcementTime)); engine->globalObject().setProperty("completeResearch", engine->newFunction(js_completeResearch)); engine->globalObject().setProperty("enableResearch", engine->newFunction(js_enableResearch)); engine->globalObject().setProperty("setPower", engine->newFunction(js_setPower)); engine->globalObject().setProperty("setTutorialMode", engine->newFunction(js_setTutorialMode)); engine->globalObject().setProperty("setDesign", engine->newFunction(js_setDesign)); engine->globalObject().setProperty("setMiniMap", engine->newFunction(js_setMiniMap)); engine->globalObject().setProperty("addReticuleButton", engine->newFunction(js_addReticuleButton)); engine->globalObject().setProperty("removeReticuleButton", engine->newFunction(js_removeReticuleButton)); engine->globalObject().setProperty("enableStructure", engine->newFunction(js_enableStructure)); engine->globalObject().setProperty("makeComponentAvailable", engine->newFunction(js_makeComponentAvailable)); engine->globalObject().setProperty("enableComponent", engine->newFunction(js_enableComponent)); engine->globalObject().setProperty("enableTemplate", engine->newFunction(js_enableTemplate)); engine->globalObject().setProperty("allianceExistsBetween", engine->newFunction(js_allianceExistsBetween)); engine->globalObject().setProperty("removeStruct", engine->newFunction(js_removeStruct)); engine->globalObject().setProperty("removeObject", engine->newFunction(js_removeObject)); engine->globalObject().setProperty("setScrollParams", engine->newFunction(js_setScrollParams)); engine->globalObject().setProperty("addStructure", engine->newFunction(js_addStructure)); engine->globalObject().setProperty("loadLevel", engine->newFunction(js_loadLevel)); engine->globalObject().setProperty("setDroidExperience", engine->newFunction(js_setDroidExperience)); engine->globalObject().setProperty("setNoGoArea", engine->newFunction(js_setNoGoArea)); engine->globalObject().setProperty("setAlliance", engine->newFunction(js_setAlliance)); engine->globalObject().setProperty("setAssemblyPoint", engine->newFunction(js_setAssemblyPoint)); // Set some useful constants engine->globalObject().setProperty("DORDER_ATTACK", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_MOVE", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_SCOUT", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_BUILD", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_HELPBUILD", 3, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_LINEBUILD", 4, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_REPAIR", 5, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_RETREAT", 6, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_PATROL", 7, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_DEMOLISH", 8, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_EMBARK", 9, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_DISEMBARK", 10, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_FIRESUPPORT", 11, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_HOLD", 12, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_RTR", 13, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_RTB", 14, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_STOP", 15, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DORDER_REARM", 16, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("COMMAND", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("BUILD", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("MANUFACTURE", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("RESEARCH", 3, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("INTELMAP", 4, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DESIGN", 5, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("CANCEL", 6, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("CAMP_CLEAN", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("CAMP_BASE", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("CAMP_WALLS", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("NO_ALLIANCES", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("ALLIANCES", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("ALLIANCES_TEAMS", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("BEING_BUILT", SS_BEING_BUILT, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("BUILT", SS_BUILT, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("BEING_DEMOLISHED", SS_BEING_DEMOLISHED, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_CONSTRUCT", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_WEAPON", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_PERSON", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_REPAIR", 3, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_SENSOR", 4, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_ECM", 5, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_CYBORG", 6, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_TRANSPORTER", 7, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID_COMMAND", 8, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("HQ", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("FACTORY", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("POWER_GEN", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("RESOURCE_EXTRACTOR", 3, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DEFENSE", 4, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("LASSAT", 5, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("WALL", 6, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("RESEARCH_LAB", 7, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("REPAIR_FACILITY", 8, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("CYBORG_FACTORY", 9, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("VTOL_FACTORY", 10, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("REARM_PAD", 11, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("SAT_UPLINK", 12, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("GATE", 13, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("COMMAND_CONTROL", 14, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("EASY", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("MEDIUM", 1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("HARD", 2, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("INSANE", 3, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("STRUCTURE", OBJ_STRUCTURE, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("DROID", OBJ_DROID, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("FEATURE", OBJ_FEATURE, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("POSITION", POSITION, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("AREA", AREA, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("ALL_PLAYERS", -1, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("ALLIES", -2, QScriptValue::ReadOnly | QScriptValue::Undeletable); QScriptValue playerData = engine->newArray(CUR_PLAYERS); for (int i = 0; i < CUR_PLAYERS; i++) { QScriptValue vector = engine->newObject(); vector.setProperty("difficulty", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("colour", 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("position", i, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("team", i, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("isAI", i != 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("isHuman", i == 0, QScriptValue::ReadOnly | QScriptValue::Undeletable); playerData.setProperty(i, vector, QScriptValue::ReadOnly | QScriptValue::Undeletable); } engine->globalObject().setProperty("playerData", playerData, QScriptValue::ReadOnly | QScriptValue::Undeletable); // Static map knowledge about start positions //== \item[derrickPositions] An array of derrick starting positions on the current map. Each item in the array is an //== object containing the x and y variables for a derrick. //== \item[startPositions] An array of player start positions on the current map. Each item in the array is an //== object containing the x and y variables for a player start position. QScriptValue startPositions = engine->newArray(CUR_PLAYERS); for (int i = 0; i < CUR_PLAYERS; i++) { QScriptValue vector = engine->newObject(); vector.setProperty("x", 40, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("y", 40, QScriptValue::ReadOnly | QScriptValue::Undeletable); startPositions.setProperty(i, vector, QScriptValue::ReadOnly | QScriptValue::Undeletable); } QScriptValue derrickPositions = engine->newArray(6); for (int i = 0; i < 6; i++) { QScriptValue vector = engine->newObject(); vector.setProperty("x", 40, QScriptValue::ReadOnly | QScriptValue::Undeletable); vector.setProperty("y", 40, QScriptValue::ReadOnly | QScriptValue::Undeletable); derrickPositions.setProperty(i, vector, QScriptValue::ReadOnly | QScriptValue::Undeletable); } engine->globalObject().setProperty("derrickPositions", derrickPositions, QScriptValue::ReadOnly | QScriptValue::Undeletable); engine->globalObject().setProperty("startPositions", startPositions, QScriptValue::ReadOnly | QScriptValue::Undeletable); QScriptSyntaxCheckResult syntax = QScriptEngine::checkSyntax(source); if (syntax.state() != QScriptSyntaxCheckResult::Valid) { qFatal("Syntax error in %s line %d: %s", path.toUtf8().constData(), syntax.errorLineNumber(), syntax.errorMessage().toUtf8().constData()); return false; } QScriptValue result = engine->evaluate(source, path); if (engine->hasUncaughtException()) { int line = engine->uncaughtExceptionLineNumber(); qFatal("Uncaught exception at line %d, file %s: %s", line, path.toUtf8().constData(), result.toString().toUtf8().constData()); return false; } // Call init callFunction(engine, "eventGameInit", QScriptValueList()); // Now set gameTime to something proper engine->globalObject().setProperty("gameTime", 10101, QScriptValue::ReadOnly | QScriptValue::Undeletable); callFunction(engine, "eventStartLevel", QScriptValueList()); callFunction(engine, "eventLaunchTransporter", QScriptValueList()); callFunction(engine, "eventReinforcementsArrived", QScriptValueList()); callFunction(engine, "eventMissionTimeout", QScriptValueList()); callFunction(engine, "eventVideoDone", QScriptValueList()); // Call other events { QScriptValueList args; args += convDroid(engine); args += convStructure(engine); callFunction(engine, "eventDroidBuilt", args); } { QScriptValueList args; args += convStructure(engine); args += convObj(engine); callFunction(engine, "eventStructureAttacked", args); } { QScriptValueList args; args += convResearch(engine); args += convStructure(engine); callFunction(engine, "eventResearched", args); } { QScriptValueList args; args += convObj(engine); args += convObj(engine); callFunction(engine, "eventAttacked", args); } { QScriptValueList args; args += convStructure(engine); args += convDroid(engine); callFunction(engine, "eventStructureBuilt", args); } { QScriptValueList args; args += convDroid(engine); callFunction(engine, "eventDroidIdle", args); } { QScriptValueList args; args += QScriptValue(0); args += QScriptValue(1); args += QScriptValue("message"); callFunction(engine, "eventChat", args); } { QScriptValueList args; args += convObj(engine); args += convObj(engine); callFunction(engine, "eventObjectSeen", args); } // Now test timers // TODO -- implement object parameters for (int i = 0; i < timers.size(); ++i) { timerNode node = timers.at(i); callFunction(node.engine, node.function, QScriptValueList(), true); } // Clean up delete engine; timers.clear(); return true; }
void App::startVoice() { rtpbin = QGst::ElementFactory::make("gstrtpbin"); if (!rtpbin) { qFatal("Failed to create gstrtpbin"); } qDebug() << "initn create"; m_pipelineOut->add(rtpbin); //audio content //sending side QGst::ElementPtr audiosrc; try { audiosrc = QGst::Bin::fromDescription( // "alsasrc device=plughw:0 ! queue ! audioconvert ! audiorate ! audio/x-raw-int,rate=8000 " // "! speexenc ! rtpspeexpay" // ); "audiotestsrc ! queue ! audioconvert ! audiorate ! audio/x-raw-int,rate=8000 ! audioconvert" ); // audiosrc = QGst::Bin::fromDescription( // "audiotestsrc ! audioconvert ! level ! audioconvert ! twolame ! rtpmpapay" // ); } catch (const QGlib::Error & error) { qCritical() << error; qFatal("One ore more required elements are missing. Aborting..."); } m_pipelineOut->add(audiosrc); volumeOut = QGst::ElementFactory::make("volume"); m_pipelineOut->add(volumeOut); // TODO settings audiosrc->link(volumeOut); QGst::ElementPtr decoder; try { decoder = QGst::Bin::fromDescription( "speexenc vad=false ! rtpspeexpay" ); } catch (const QGlib::Error & error) { qCritical() << error; qFatal("One ore more required elements are missing. Aborting..."); } m_pipelineOut->add(decoder); volumeOut->link(decoder); decoder->link(rtpbin, "send_rtp_sink_1"); rtpudpsink = QGst::ElementFactory::make("udpsink"); if (!rtpudpsink) { qFatal("Failed to create udpsink. Aborting..."); } rtpudpsink->setProperty("host", "127.0.0.1"); // desttination 192.168.0.102 rtpudpsink->setProperty("port", 5000); // port m_pipelineOut->add(rtpudpsink); rtpbin->link("send_rtp_src_1", rtpudpsink); }
KSMServer::KSMServer( const QString& windowManager, bool _only_local, bool lockscreen ) : wmProcess( NULL ) , sessionGroup( "" ) , logoutEffectWidget( NULL ) { #ifdef COMPILE_SCREEN_LOCKER KGlobal::locale()->insertCatalog(QLatin1String( "libkworkspace" )); ScreenLocker::KSldApp::self(); if (lockscreen) { ScreenLocker::KSldApp::self()->lock(); } #else Q_UNUSED(lockscreen) #endif new KSMServerInterfaceAdaptor( this ); QDBusConnection::sessionBus().registerObject("/KSMServer", this); klauncherSignals = new OrgKdeKLauncherInterface(QLatin1String("org.kde.klauncher"), QLatin1String("/KLauncher"), QDBusConnection::sessionBus()); kcminitSignals = NULL; the_server = this; clean = false; shutdownType = KWorkSpace::ShutdownTypeNone; state = Idle; dialogActive = false; saveSession = false; wmPhase1WaitingCount = 0; KConfigGroup config(KGlobal::config(), "General"); clientInteracting = 0; xonCommand = config.readEntry( "xonCommand", "xon" ); KGlobal::dirs()->addResourceType( "windowmanagers", "data", "ksmserver/windowmanagers" ); selectWm( windowManager ); connect( &startupSuspendTimeoutTimer, SIGNAL(timeout()), SLOT(startupSuspendTimeout())); connect( &pendingShutdown, SIGNAL(timeout()), SLOT(pendingShutdownTimeout())); only_local = _only_local; #ifdef HAVE__ICETRANSNOLISTEN if (only_local) _IceTransNoListen("tcp"); #else only_local = false; #endif char errormsg[256]; if (!SmsInitialize ( (char*) KSMVendorString, (char*) KSMReleaseString, KSMNewClientProc, (SmPointer) this, HostBasedAuthProc, 256, errormsg ) ) { qWarning("KSMServer: could not register XSM protocol"); } if (!IceListenForConnections (&numTransports, &listenObjs, 256, errormsg)) { qWarning("KSMServer: Error listening for connections: %s", errormsg); qWarning("KSMServer: Aborting."); exit(1); } { // publish available transports. QByteArray fName = QFile::encodeName(KStandardDirs::locateLocal("socket", "KSMserver")); QString display = ::getenv("DISPLAY"); // strip the screen number from the display display.replace(QRegExp("\\.[0-9]+$"), ""); int i; while( (i = display.indexOf(':')) >= 0) display[i] = '_'; while( (i = display.indexOf('/')) >= 0) display[i] = '_'; fName += '_'+display.toLocal8Bit(); FILE *f; f = ::fopen(fName.data(), "w+"); if (!f) { qWarning("KSMServer: cannot open %s: %s", fName.data(), strerror(errno)); qWarning("KSMServer: Aborting."); exit(1); } char* session_manager = IceComposeNetworkIdList(numTransports, listenObjs); fprintf(f, "%s\n%i\n", session_manager, getpid()); fclose(f); setenv( "SESSION_MANAGER", session_manager, true ); // Pass env. var to kdeinit. org::kde::KLauncher klauncher("org.kde.klauncher", "/KLauncher", QDBusConnection::sessionBus()); klauncher.setLaunchEnv( "SESSION_MANAGER", (const char*) session_manager ); free(session_manager); } if (only_local) { if (!SetAuthentication_local(numTransports, listenObjs)) qFatal("KSMSERVER: authentication setup failed."); } else { if (!SetAuthentication(numTransports, listenObjs, &authDataEntries)) qFatal("KSMSERVER: authentication setup failed."); } IceAddConnectionWatch (KSMWatchProc, (IcePointer) this); KSMListener* con; for ( int i = 0; i < numTransports; i++) { fcntl( IceGetListenConnectionNumber( listenObjs[i] ), F_SETFD, FD_CLOEXEC ); con = new KSMListener( listenObjs[i] ); listener.append( con ); connect( con, SIGNAL(activated(int)), this, SLOT(newConnection(int)) ); } signal(SIGHUP, sighandler); signal(SIGTERM, sighandler); signal(SIGINT, sighandler); signal(SIGPIPE, SIG_IGN); connect( &protectionTimer, SIGNAL(timeout()), this, SLOT(protectionTimeout()) ); connect( &restoreTimer, SIGNAL(timeout()), this, SLOT(tryRestoreNext()) ); connect( qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanUp()) ); }
QT_BEGIN_NAMESPACE static void copyArgument(void *to, int id, const QVariant &arg) { if (id == arg.userType()) { switch (id) { case QVariant::Bool: *reinterpret_cast<bool *>(to) = arg.toBool(); return; case QMetaType::UChar: *reinterpret_cast<uchar *>(to) = arg.value<uchar>(); return; case QMetaType::Short: *reinterpret_cast<short *>(to) = arg.value<short>(); return; case QMetaType::UShort: *reinterpret_cast<ushort *>(to) = arg.value<ushort>(); return; case QVariant::Int: *reinterpret_cast<int *>(to) = arg.toInt(); return; case QVariant::UInt: *reinterpret_cast<uint *>(to) = arg.toUInt(); return; case QVariant::LongLong: *reinterpret_cast<qlonglong *>(to) = arg.toLongLong(); return; case QVariant::ULongLong: *reinterpret_cast<qulonglong *>(to) = arg.toULongLong(); return; case QVariant::Double: *reinterpret_cast<double *>(to) = arg.toDouble(); return; case QVariant::String: *reinterpret_cast<QString *>(to) = arg.toString(); return; case QVariant::ByteArray: *reinterpret_cast<QByteArray *>(to) = arg.toByteArray(); return; case QVariant::StringList: *reinterpret_cast<QStringList *>(to) = arg.toStringList(); return; } if (id == QDBusMetaTypeId::variant()) { *reinterpret_cast<QDBusVariant *>(to) = arg.value<QDBusVariant>(); return; } else if (id == QDBusMetaTypeId::objectpath()) { *reinterpret_cast<QDBusObjectPath *>(to) = arg.value<QDBusObjectPath>(); return; } else if (id == QDBusMetaTypeId::signature()) { *reinterpret_cast<QDBusSignature *>(to) = arg.value<QDBusSignature>(); return; } // those above are the only types possible // the demarshaller code doesn't demarshall anything else qFatal("Found a decoded basic type in a D-Bus reply that shouldn't be there"); } // if we got here, it's either an un-dermarshalled type or a mismatch if (arg.userType() != QDBusMetaTypeId::argument()) { // it's a mismatch //qWarning? return; } // is this type registered? const char *userSignature = QDBusMetaType::typeToSignature(id); if (!userSignature || !*userSignature) { // type not registered //qWarning? return; } // is it the same signature? QDBusArgument dbarg = arg.value<QDBusArgument>(); if (dbarg.currentSignature() != QLatin1String(userSignature)) { // not the same signature, another mismatch //qWarning? return; } // we can demarshall QDBusMetaType::demarshall(dbarg, id, to); }
void Protocol::list() { qFatal("Base Protocol list() called"); }
void FxChannel::doProcessing() { const fpp_t fpp = Engine::mixer()->framesPerPeriod(); const bool exporting = Engine::getSong()->isExporting(); if( m_muted == false ) { for( FxRoute * senderRoute : m_receives ) { FxChannel * sender = senderRoute->sender(); FloatModel * sendModel = senderRoute->amount(); if( ! sendModel ) qFatal( "Error: no send model found from %d to %d", senderRoute->senderIndex(), m_channelIndex ); if( sender->m_hasInput || sender->m_stillRunning ) { // figure out if we're getting sample-exact input ValueBuffer * sendBuf = sendModel->valueBuffer(); ValueBuffer * volBuf = sender->m_volumeModel.valueBuffer(); // mix it's output with this one's output sampleFrame * ch_buf = sender->m_buffer; // use sample-exact mixing if sample-exact values are available if( ! volBuf && ! sendBuf ) // neither volume nor send has sample-exact data... { const float v = sender->m_volumeModel.value() * sendModel->value(); if( exporting ) { MixHelpers::addSanitizedMultiplied( m_buffer, ch_buf, v, fpp ); } else { MixHelpers::addMultiplied( m_buffer, ch_buf, v, fpp ); } } else if( volBuf && sendBuf ) // both volume and send have sample-exact data { if( exporting ) { MixHelpers::addSanitizedMultipliedByBuffers( m_buffer, ch_buf, volBuf, sendBuf, fpp ); } else { MixHelpers::addMultipliedByBuffers( m_buffer, ch_buf, volBuf, sendBuf, fpp ); } } else if( volBuf ) // volume has sample-exact data but send does not { const float v = sendModel->value(); if( exporting ) { MixHelpers::addSanitizedMultipliedByBuffer( m_buffer, ch_buf, v, volBuf, fpp ); } else { MixHelpers::addMultipliedByBuffer( m_buffer, ch_buf, v, volBuf, fpp ); } } else // vice versa { const float v = sender->m_volumeModel.value(); if( exporting ) { MixHelpers::addSanitizedMultipliedByBuffer( m_buffer, ch_buf, v, sendBuf, fpp ); } else { MixHelpers::addMultipliedByBuffer( m_buffer, ch_buf, v, sendBuf, fpp ); } } m_hasInput = true; } } const float v = m_volumeModel.value(); if( m_hasInput ) { // only start fxchain when we have input... m_fxChain.startRunning(); } m_stillRunning = m_fxChain.processAudioBuffer( m_buffer, fpp, m_hasInput ); float peakLeft = 0.; float peakRight = 0.; Engine::mixer()->getPeakValues( m_buffer, fpp, peakLeft, peakRight ); m_peakLeft = qMax( m_peakLeft, peakLeft * v ); m_peakRight = qMax( m_peakRight, peakRight * v ); } else { m_peakLeft = m_peakRight = 0.0f; } // increment dependency counter of all receivers processed(); }
void Server::initializeCert() { QByteArray crt, key, pass, dhparams; crt = getConf("certificate", QString()).toByteArray(); key = getConf("key", QString()).toByteArray(); pass = getConf("passphrase", QByteArray()).toByteArray(); dhparams = getConf("sslDHParams", Meta::mp.qbaDHParams).toByteArray(); QList<QSslCertificate> ql; if (! key.isEmpty()) { qskKey = QSslKey(key, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, pass); if (qskKey.isNull()) qskKey = QSslKey(key, QSsl::Dsa, QSsl::Pem, QSsl::PrivateKey, pass); } if (qskKey.isNull() && ! crt.isEmpty()) { qskKey = QSslKey(crt, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, pass); if (qskKey.isNull()) qskKey = QSslKey(crt, QSsl::Dsa, QSsl::Pem, QSsl::PrivateKey, pass); } if (! qskKey.isNull()) { ql << QSslCertificate::fromData(crt); ql << QSslCertificate::fromData(key); for (int i=0;i<ql.size();++i) { const QSslCertificate &c = ql.at(i); if (isKeyForCert(qskKey, c)) { qscCert = c; ql.removeAt(i); } } qlCA = ql; } #if defined(USE_QSSLDIFFIEHELLMANPARAMETERS) if (! dhparams.isEmpty()) { QSslDiffieHellmanParameters qdhp = QSslDiffieHellmanParameters(dhparams); if (qdhp.isValid()) { qsdhpDHParams = qdhp; } else { log(QString::fromLatin1("Unable to use specified Diffie-Hellman parameters (sslDHParams): %1").arg(qdhp.errorString())); } } #else if (! dhparams.isEmpty()) { log("Diffie-Hellman parameters (sslDHParams) were specified, but will not be used. This version of Murmur does not support Diffie-Hellman parameters."); } #endif QString issuer; #if QT_VERSION >= 0x050000 QStringList issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName); if (! issuerNames.isEmpty()) { issuer = issuerNames.first(); } #else issuer = qscCert.issuerInfo(QSslCertificate::CommonName); #endif if (issuer == QString::fromUtf8("Murmur Autogenerated Certificate")) { log("Old autogenerated certificate is unusable for registration, invalidating it"); qscCert = QSslCertificate(); qskKey = QSslKey(); } if (!qscCert.isNull() && issuer == QString::fromUtf8("Murmur Autogenerated Certificate v2") && ! Meta::mp.qscCert.isNull() && ! Meta::mp.qskKey.isNull() && (Meta::mp.qlBind == qlBind)) { qscCert = Meta::mp.qscCert; qskKey = Meta::mp.qskKey; } if (qscCert.isNull() || qskKey.isNull()) { if (! key.isEmpty() || ! crt.isEmpty()) { log("Certificate specified, but failed to load."); } qskKey = Meta::mp.qskKey; qscCert = Meta::mp.qscCert; if (qscCert.isNull() || qskKey.isNull()) { log("Generating new server certificate."); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); X509 *x509 = X509_new(); EVP_PKEY *pkey = EVP_PKEY_new(); RSA *rsa = RSA_generate_key(2048,RSA_F4,NULL,NULL); EVP_PKEY_assign_RSA(pkey, rsa); X509_set_version(x509, 2); ASN1_INTEGER_set(X509_get_serialNumber(x509),1); X509_gmtime_adj(X509_get_notBefore(x509),0); X509_gmtime_adj(X509_get_notAfter(x509),60*60*24*365*20); X509_set_pubkey(x509, pkey); X509_NAME *name=X509_get_subject_name(x509); X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, reinterpret_cast<unsigned char *>(const_cast<char *>("Murmur Autogenerated Certificate v2")), -1, -1, 0); X509_set_issuer_name(x509, name); add_ext(x509, NID_basic_constraints, SSL_STRING("critical,CA:FALSE")); add_ext(x509, NID_ext_key_usage, SSL_STRING("serverAuth,clientAuth")); add_ext(x509, NID_subject_key_identifier, SSL_STRING("hash")); add_ext(x509, NID_netscape_comment, SSL_STRING("Generated from murmur")); X509_sign(x509, pkey, EVP_sha1()); crt.resize(i2d_X509(x509, NULL)); unsigned char *dptr=reinterpret_cast<unsigned char *>(crt.data()); i2d_X509(x509, &dptr); qscCert = QSslCertificate(crt, QSsl::Der); if (qscCert.isNull()) log("Certificate generation failed"); key.resize(i2d_PrivateKey(pkey, NULL)); dptr=reinterpret_cast<unsigned char *>(key.data()); i2d_PrivateKey(pkey, &dptr); qskKey = QSslKey(key, QSsl::Rsa, QSsl::Der); if (qskKey.isNull()) log("Key generation failed"); setConf("certificate", qscCert.toPem()); setConf("key", qskKey.toPem()); } } #if defined(USE_QSSLDIFFIEHELLMANPARAMETERS) if (qsdhpDHParams.isEmpty()) { log("Generating new server 2048-bit Diffie-Hellman parameters. This could take a while..."); DH *dh = DH_new(); if (dh == NULL) { qFatal("DH_new failed: unable to generate Diffie-Hellman parameters for virtual server"); } // Generate DH params. // We register a status callback in order to update the UI // for Murmur on Windows. We don't show the actual status, // but we do it to keep Murmur on Windows responsive while // generating the parameters. BN_GENCB cb; memset(&cb, 0, sizeof(BN_GENCB)); BN_GENCB_set(&cb, dh_progress, NULL); if (DH_generate_parameters_ex(dh, 2048, 2, &cb) == 0) { qFatal("DH_generate_parameters_ex failed: unable to generate Diffie-Hellman parameters for virtual server"); } BIO *mem = BIO_new(BIO_s_mem()); if (PEM_write_bio_DHparams(mem, dh) == 0) { qFatal("PEM_write_bio_DHparams failed: unable to write generated Diffie-Hellman parameters to memory"); } char *pem = NULL; long len = BIO_get_mem_data(mem, &pem); if (len <= 0) { qFatal("BIO_get_mem_data returned an empty or invalid buffer"); } QByteArray pemdh(pem, len); QSslDiffieHellmanParameters qdhp(pemdh); if (!qdhp.isValid()) { qFatal("QSslDiffieHellmanParameters: unable to import generated Diffie-HellmanParameters: %s", qdhp.errorString().toStdString().c_str()); } qsdhpDHParams = qdhp; setConf("sslDHParams", pemdh); BIO_free(mem); DH_free(dh); } #endif }
void Modifier::initTestCase() { const auto state = s_process->state(); if (state != QProcess::NotRunning && m_action == Start) { qFatal("Already running"); } switch (m_action) { case Start: { qDebug() << "Starting..."; QRegularExpression nonxdg(QStringLiteral("^[^X][^D][^G].*$")); auto env = QProcessEnvironment::systemEnvironment().toStringList() .filter(nonxdg) << QStringLiteral("XDG_DATA_HOME=") + s_tempDir->path() + QStringLiteral("/") << QStringLiteral("XDG_CONFIG_HOME=") + s_tempDir->path() + QStringLiteral("/") << QStringLiteral("XDG_CACHE_HOME=") + s_tempDir->path() + QStringLiteral("/"); // qDebug() << env; s_process->setEnvironment(env); s_process->start(QStringLiteral("kactivitymanagerd")); s_process->waitForStarted(); break; } case Stop: case Kill: case Crash: { qDebug() << "Stopping..."; const auto dbus = QDBusConnection::sessionBus().interface(); const auto kamd = KAMD_DBUS_SERVICE; if (!dbus->isServiceRegistered(kamd)) break; uint pid = dbus->servicePid(kamd); ::kill(pid, m_action == Stop ? SIGQUIT : m_action == Kill ? SIGKILL : /* else */ SIGSEGV ); while (Test::isActivityManagerRunning()) { QCoreApplication::processEvents(); } if (s_process->state() == QProcess::Running) { s_process->terminate(); s_process->waitForFinished(); } break; } } }
QString GetConfigPath(ConfigPath config) { switch (config) { case Path_Root: { if (Application::kIsPortable) { return QString("%1/data").arg(QCoreApplication::applicationDirPath()); } #ifdef Q_OS_DARWIN return mac::GetApplicationSupportPath() + "/" + QCoreApplication::organizationName(); #else return QString("%1/.config/%2") .arg(QDir::homePath(), QCoreApplication::organizationName()); #endif } break; case Path_CacheRoot: { if (Application::kIsPortable) { return GetConfigPath(Path_Root) + "/cache"; } #if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) char* xdg = getenv("XDG_CACHE_HOME"); if (!xdg || !*xdg) { return QString("%1/.cache/%2") .arg(QDir::homePath(), QCoreApplication::organizationName()); } else { return QString("%1/%2").arg(xdg, QCoreApplication::organizationName()); } #else return GetConfigPath(Path_Root); #endif } break; case Path_AlbumCovers: return GetConfigPath(Path_Root) + "/albumcovers"; case Path_NetworkCache: return GetConfigPath(Path_CacheRoot) + "/networkcache"; case Path_MoodbarCache: return GetConfigPath(Path_CacheRoot) + "/moodbarcache"; case Path_GstreamerRegistry: return GetConfigPath(Path_Root) + QString("/gst-registry-%1-bin") .arg(QCoreApplication::applicationVersion()); case Path_DefaultMusicLibrary: #ifdef Q_OS_DARWIN return mac::GetMusicDirectory(); #else return QDir::homePath(); #endif case Path_LocalSpotifyBlob: return GetConfigPath(Path_Root) + "/spotifyblob"; default: qFatal("%s", Q_FUNC_INFO); return QString::null; } }
void QgsLogger::fatal( const QString& msg ) { logMessageToFile( msg ); qFatal( "%s", msg.toLocal8Bit().constData() ); }
bool RC2UI::makeDialog() { line = in->readLine(); do { QFile fileOut; QString buffer; int count; QCString className; uint x, y, w, h; uint endDesc; bool space = FALSE; for ( endDesc = 0; endDesc < line.length() ; endDesc++ ) { char c = (QChar)line.at(endDesc); if ( space && (c >= '0') && (c <= '9') ) break; space = c==' '; } QString desc = line.left(endDesc-1); line = line.right( line.length() - endDesc ); className = parseNext( desc, ' ' ); count = sscanf( line, "%u, %u, %u, %u", &x, &y, &w, &h ); if ( !count && count == EOF ) return FALSE; char property[256]; QStringList styles; QStringList extendedStyles; QString caption = ""; QString baseClass = ""; QString widgetType; QString widgetName; QString arguments; int pointsize = 10; QString fontname; do { line = ""; do { if ( in->eof() ) return TRUE; line += in->readLine(); } while ( line[(int)line.length()-1] == '|' || line[(int)line.length()-1] == ',' ); count = sscanf( line, "%s", property ); line = line.right( line.length() - line.find(" ") -1 ); if ( QString(property) == "STYLE" ) { styles = splitStyles(line); if ( styles.contains( "WS_CAPTION" ) ) baseClass = "QDialog"; else baseClass = "QWidget"; } else if ( QString(property) == "CAPTION" ) { caption = stripQM( line ); } else if ( QString(property) == "FONT" ) { QString pt = line.left( line.find(",") ); pointsize = pt.toInt(); fontname = stripQM(line.right( line.length() - line.find(",") - 2 )); } } while ( line != "BEGIN" ); if ( writeToFile ) { QString outputFile = QString(className) + ".ui"; fileOut.setName( outputFile ); if (!fileOut.open( IO_WriteOnly ) ) qFatal( "rc2ui: Could not open output file '%s'", outputFile.latin1() ); out = new QTextStream( &fileOut ); targetFiles.append( outputFile ); } else { out = new QTextStream( &buffer, IO_WriteOnly ); } *out << "<!DOCTYPE UI><UI>" << endl; writeClass( className ); wi(); *out << "<widget>"<< endl; indent(); writeClass( baseClass ); writeCString( "name", className ); writeRect( "geometry", x, y, w, h ); writeString( "caption", caption ); writeFont( fontname, pointsize ); do { if ( in->eof() ) return TRUE; line = in->readLine().stripWhiteSpace(); if ( line == "END" ) continue; widgetType = parseNext(line, ' '); arguments = line.stripWhiteSpace(); while ( arguments[(int)arguments.length()-1] == ',' || arguments[(int)arguments.length()-1] == '|' ) arguments += " "+in->readLine().stripWhiteSpace(); wi(); *out << "<widget>" << endl; indent(); WidgetType ID = IDUnknown; QString controlType; QString widgetID; QString widgetText; bool hasText = FALSE; bool isControl = FALSE; bool isFrame = FALSE; if ( widgetType == "PUSHBUTTON" ) { ID = IDPushButton; hasText = TRUE; } else if ( widgetType == "DEFPUSHBUTTON" ) { ID = IDPushButton; hasText = TRUE; } else if ( widgetType == "LTEXT" ) { ID = IDLabel; hasText = TRUE; } else if ( widgetType == "CTEXT" ) { ID = IDLabel; hasText = TRUE; } else if ( widgetType == "RTEXT" ) { ID = IDLabel; hasText = TRUE; } else if ( widgetType == "EDITTEXT" ) { ID = IDLineEdit; } else if ( widgetType == "GROUPBOX" ) { ID = IDGroupBox; hasText = TRUE; } else if ( widgetType == "COMBOBOX" ) { ID = IDComboBox; } else if ( widgetType == "LISTBOX" ) { ID = IDListBox; } else if ( widgetType == "SCROLLBAR" ) { ID = IDScrollBar; } else if ( widgetType == "CHECKBOX" ) { ID = IDCheckBox; hasText = TRUE; } else if ( widgetType == "RADIOBUTTON" ) { ID = IDRadioButton; hasText = TRUE; } else if ( widgetType == "CONTROL" ) { isControl = TRUE; widgetText = stripQM(parseNext( arguments )); widgetID = parseNext( arguments ); controlType = stripQM(parseNext( arguments )); styles = splitStyles(parseNext( arguments )); if ( controlType == "Static" ) { ID = IDLabel; } else if ( controlType == "Button" ) { if ( styles.contains("BS_AUTOCHECKBOX") || styles.contains("BS_3STATE") ) ID = IDCheckBox; else if ( styles.contains("BS_AUTORADIOBUTTON") ) ID = IDRadioButton; } else if ( controlType == "msctls_updown32" ) { ID = IDSpinBox; } else if ( controlType == "msctls_progress32" ) { ID = IDProgressBar; } else if ( controlType == "msctls_trackbar32" ) { ID = IDSlider; } else if ( controlType == "SysListView32" ) { ID = IDIconView; } else if ( controlType == "SysTreeView32" ) { ID = IDListView; } else if ( controlType == "SysTabControl32" ) { ID = IDTabWidget; } else if ( controlType == "SysAnimate32" ) { ID = IDLabel; } else if ( controlType == "RICHEDIT" ) { ID = IDMultiLineEdit; } else if ( controlType == "ComboBoxEx32" ) { ID = IDComboBox; } else if ( controlType == "" ) { ID = IDCustom; } else { ID = IDUnknown; } } else ID = IDUnknown; if ( hasText ) widgetText = stripQM(parseNext( arguments )); if ( isControl ) { x = parseNext( arguments ).toInt(); y = parseNext( arguments ).toInt(); w = parseNext( arguments ).toInt(); h = parseNext( arguments ).toInt(); } else { widgetID = parseNext( arguments ); x = parseNext( arguments ).toInt(); y = parseNext( arguments ).toInt(); w = parseNext( arguments ).toInt(); h = parseNext( arguments ).toInt(); styles.clear(); } do { extendedStyles = splitStyles(parseNext( arguments )); for ( uint i = 0; i < extendedStyles.count(); i++ ) styles << (*extendedStyles.at(i)); } while ( arguments.find(',') > -1 ); switch ( ID ) { case IDWidget: break; case IDPushButton: { writeClass("QPushButton"); writeCString( "name", useName("PushButton_"+widgetID) ); writeRect( "geometry", x, y, w, h ); writeString( "text", widgetText ); if ( widgetType == "DEFPUSHBUTTON" ) writeBool( "default", TRUE ); } break; case IDLabel: { isFrame = TRUE, writeClass("QLabel"); writeCString( "name", useName("Label_"+widgetID) ); writeRect( "geometry", x,y,w,h ); writeString( "text", widgetText ); QString align; if ( !styles.contains("SS_CENTERIMAGE") ) align += "|AlignTop"; else align += "|AlignVCenter"; if ( widgetType == "LTEXT" ) { align += "|AlignLeft"; } else if ( widgetType == "CTEXT") { align += "|AlignHCenter"; } else if ( widgetType == "RTEXT") { align += "|AlignRight"; } writeSet("alignment", align ); } break; case IDCheckBox: { writeClass("QCheckBox"); writeCString("name", useName("CheckBox_"+widgetID) ); writeRect("geometry", x,y,w,h); writeString("text", widgetText ); if ( styles.contains( "BS_3STATE" ) ) writeBool( "tristate", TRUE ); } break; case IDRadioButton: { writeClass("QRadioButton"); writeCString("name", useName("RadioButton_"+widgetID) ); writeRect("geometry", x,y,w,h); writeString("text", widgetText ); } break; case IDGroupBox: { isFrame = TRUE; writeClass("QGroupBox"); writeCString( "name", useName("GroupBox_"+widgetID) ); writeRect( "geometry", x,y,w,h ); writeString( "title", widgetText ); if ( !styles.contains( "WS_BORDER" ) ) styles.append( "WS_BORDER" ); } break; case IDLineEdit: { if ( !styles.contains("ES_MULTILINE") ) { writeClass("QLineEdit"); writeCString( "name", useName("LineEdit_"+widgetID) ); } else { writeClass("QMultiLineEdit"); writeCString( "name", useName("MultiLineEdit_"+widgetID) ); } writeRect( "geometry", x,y,w,h ); QString align = "AlignTop"; if ( styles.contains("ES_CENTER") ) align+="|AlignHCenter"; else if ( styles.contains("ES_RIGHT") ) align+="|AlignRight"; else align+="|AlignLeft"; writeSet("alignment", align); } break; case IDMultiLineEdit: { writeClass("QMultiLineEdit"); writeCString("name", useName("MultiLineEdit_"+widgetID) ); writeRect("geometry", x,y,w,h ); } break; case IDIconView: { isFrame = TRUE; writeClass("QIconView"); writeCString("name", useName("IconView_"+widgetID) ); writeRect("geometry", x,y,w,h ); if ( !styles.contains( "LVS_SINGLESEL" ) ) writeEnum( "selectionMode", "Extended" ); if ( styles.contains( "LVS_NOLABELWRAP" ) ) writeBool("wordWrapIconText", FALSE ); } break; case IDListView: { isFrame = TRUE; writeClass("QListView"); writeCString("name", useName("ListView_"+widgetID) ); writeRect("geometry", x,y,w,h ); if ( styles.contains( "TVS_LINESATROOT" ) ) writeBool( "rootIsDecorated", TRUE ); if ( styles.contains( "TVS_FULLROWSELECT" ) ) writeBool( "allColumnsShowFocus", TRUE ); } break; case IDProgressBar: { isFrame = TRUE; writeClass("QProgressBar"); writeCString("name", useName("ProgressBar_"+widgetID) ); writeRect("geometry", x,y,w,h ); if ( styles.contains("TBS_VERT") ) writeEnum("orientation", "Vertical"); else writeEnum("orientation", "Horizontal"); } break; case IDTabWidget: { writeClass("QTabWidget"); writeCString("name", useName("TabWidget_"+widgetID) ); writeRect("geometry", x,y,w,h ); wi(); *out << "<widget>" << endl; indent(); writeClass("QWidget"); wi(); *out << "<attribute>" << endl; indent(); wi(); *out << "<name>title</name>" << endl; wi(); *out << "<string>Tab1</string>" << endl; undent(); wi(); *out << "</attribute>" << endl; undent(); wi(); *out << "</widget>" << endl; } break; case IDSpinBox: { isFrame = TRUE; writeClass("QSpinBox"); writeCString("name", useName("SpinBox_"+widgetID) ); writeRect("geometry", x,y,w,h); } break; case IDSlider: { writeClass("QSlider"); writeCString("name", useName("Slider_"+widgetID) ); writeRect("geometry", x,y,w,h ); if ( styles.contains("TBS_VERT") ) writeEnum("orientation", "Vertical"); else writeEnum("orientation", "Horizontal"); if ( !styles.contains("TBS_NOTICKS") ) writeEnum("tickmarks", "Left" ); } break; case IDComboBox: { writeClass("QComboBox"); writeCString("name", useName("ComboBox_"+widgetID) ); if ( isControl ) writeRect( "geometry", x,y,w,14 ); else writeRect( "geometry", x,y,w,h ); } break; case IDListBox: { isFrame = TRUE; writeClass("QListBox"); writeCString("name", useName("ListBox_"+widgetID) ); writeRect( "geometry", x,y,w,h ); if ( styles.contains("WS_HSCROLL") ) writeEnum("hScrollBarMode", "Auto"); else writeEnum("hScrollBarMode", "AlwaysOff"); if ( styles.contains("WS_VSCROLL") ) writeEnum("vScrollBarMode", "Auto"); else writeEnum("vScrollBarMode", "AlwaysOff"); if ( styles.contains("LBS_EXTENDEDSEL") ) writeEnum("selectionMode", "Extended"); else if ( styles.contains("LBS_MULTIPLESEL") ) writeEnum("selectionMode", "Multi"); else if ( styles.contains("LBS_NOSEL") ) writeEnum("selectionMode", "NoSelection"); else writeEnum("selectionMode", "Single"); if ( !styles.contains( "NO WS_BORDER" ) ) styles.append( "WS_BORDER" ); } break; case IDScrollBar: { writeClass("QScrollBar"); writeCString("name", useName("ScrollBar_"+widgetID) ); writeRect("geometry", x,y,w,h ); if ( styles.contains("SBS_VERT") ) writeEnum("orientation", "Vertical"); else writeEnum("orientation", "Horizontal"); } break; case IDCustom: { writeClass("QLabel"); writeCString("name", useName("Custom_"+widgetID) ); writeRect("geometry", x,y,w,h ); writeString("text", "Create a custom widget and place it here." ); } default: { writeClass("QLabel"); writeCString("name", useName("Unknown_"+widgetID) ); writeRect("geometry", x,y,w,h ); writeString("text", QString("No support for %1.").arg(controlType) ); } break; } writeStyles( styles, isFrame ); styles.clear(); undent(); wi(); *out << "</widget>" << endl; } while ( line != "END" ); undent(); wi(); *out << "</widget>" << endl; *out << "</UI>" << endl; do { line = in->readLine(); } while ( line.isEmpty() ); if ( !writeToFile ) target.append( buffer.copy() ); if (out) { delete out; out = 0; } fileOut.close(); } while ( line != blockStart1 ); return TRUE; }
~RunAtExit() { int *ptr = checkedAfterDestruction(); if (ptr) qFatal("Global static is not null as was expected"); }