void DBusXMLScanner::parseInput(const char * fileName, const char * /* fileBuf */, Entry *root, bool /*sameTranslationUnit*/, QStrList & /*filesInSameTranslationUnit*/) { QFile inputFile(fileName); QXmlInputSource inputSource(inputFile); QXmlSimpleReader reader; DBusXMLHandler handler(this, &reader, fileName, root); reader.setContentHandler(&handler); reader.setErrorHandler(&handler); reader.setLexicalHandler(&handler); groupEnterFile(fileName, 1); handler.setSection(); reader.parse(inputSource); if (!handler.errorString().isEmpty()) { err("DBus XML Parser: Error at line %d: %s\n", handler.locator()->lineNumber(),handler.errorString().utf8().data()); } groupLeaveFile(fileName, 1); }
void VCSlider::slotInputValueChanged(quint32 universe, quint32 channel, uchar value) { /* Don't let input data thru in design mode */ if (mode() == Doc::Design) return; if (inputSource() == QLCInputSource(universe, channel)) { if (isButton(universe, channel) == true) { // Check value here so that value == 0 won't end up in the else branch if (value > 0) slotTapButtonClicked(); } else { /* Scale from input value range to this slider's range */ float val; val = SCALE((float) value, (float) 0, (float) UCHAR_MAX, (float) m_slider->minimum(), (float) m_slider->maximum()); if (m_slider->invertedAppearance() == true) m_slider->setValue(m_slider->maximum() - (int) val); else m_slider->setValue((int) val); } } }
size_t AudioRecord::frameSize() const { if (inputSource() == AUDIO_SOURCE_VOICE_COMMUNICATION) { if (audio_is_linear_pcm(mFormat)) { return channelCount()*audio_bytes_per_sample(mFormat); } else { return channelCount()*sizeof(int16_t); } } else { if (format() ==AUDIO_FORMAT_AMR_NB) { return channelCount() * AMR_FRAMESIZE; // Full rate framesize } else if (format() == AUDIO_FORMAT_EVRC) { return channelCount() * EVRC_FRAMESIZE; // Full rate framesize } else if (format() == AUDIO_FORMAT_QCELP) { return channelCount() * QCELP_FRAMESIZE; // Full rate framesize } else if (format() == AUDIO_FORMAT_AAC) { // Not actual framsize but for variable frame rate AAC encoding, // buffer size is treated as a frame size return AAC_FRAMESIZE; } else if(format() == AUDIO_FORMAT_AMR_WB) { return channelCount() * AMR_WB_FRAMESIZE; } if (audio_is_linear_pcm(mFormat)) { return channelCount()*audio_bytes_per_sample(mFormat); } else { return sizeof(uint8_t); } } }
bool ProjectXML::readFile(QFile *pfile) { QXmlInputSource inputSource(pfile); QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); return reader.parse(inputSource); }
PanelChecklist::PanelChecklist(QSize sz, QWidget *pParent) : AbstractPanel(sz, pParent) { setFixedSize(sz); GraphicsSingleton* pG = GraphicsSingleton::GetInstance(); const QFont& font = pG->GetFont(GraphicsSingleton::fDialog); // Main layout QHBoxLayout* pMainLayout = new QHBoxLayout; setLayout(pMainLayout); // Check list (left column) layout QVBoxLayout* pCheckLayout = new QVBoxLayout; // pCheckLayout->addWidget(new QLabel(tr("Checklist"))); m_plwCheck = new NesisListWidget(); m_plwCheck->setMaximumWidth(180); m_plwCheck->setFont(font); pCheckLayout->addWidget(m_plwCheck); pMainLayout->addLayout(pCheckLayout); QVBoxLayout* pContentLayout = new QVBoxLayout; // pContentLayout->addWidget(new QLabel(tr("Content"))); m_pwContent = new WidgetChecklist(this); pContentLayout->addWidget(m_pwContent); pContentLayout->setStretchFactor(m_pwContent, 100); pMainLayout->addLayout(pContentLayout); // Tune the layout. pMainLayout->setStretchFactor(pContentLayout, 100); // Load data from the file. Settings* pSettings = Settings::GetInstance(); QFile file(pSettings->GetCheckListPath() + QString("DefaultCheck.xml")); QXmlInputSource inputSource(&file); QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); m_pCheckItem = NULL; reader.parse(inputSource); // Connections connect( m_plwCheck->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(OnCurrentRowChanged(const QModelIndex&, const QModelIndex&)) ); // Connect main widget with direct buttons connect(m_plwCheck, SIGNAL(NesisButton(int)), GetWidgetMain(), SLOT(ActivatePanel(int))); // Set initial selection m_plwCheck->setCurrentRow(0); // qDebug() << "CL:C:Finish"; }
bool KMLReader::readFile(const QString &fileName) { QFile file(fileName); QXmlInputSource inputSource(&file); QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); return reader.parse(inputSource); }
/** * @brief Konstruktor * * erzeugt einen neuen SAX-Parser und liest automatisch die Datei * mit dem uebergebenen Pfad/-Dateinamen ein * * @param filename Dateiname, der XML-Datei, die eingelesen werden soll */ SAX::SAX(QString &filename) { QFile file(filename); QXmlInputSource inputSource(&file); QXmlSimpleReader reader; reader.setContentHandler(this); /* Als Handler 'this'-Handler */ reader.setErrorHandler(this); reader.parse(inputSource); /* Datei mit Namen 'filename' einlesen */ }
void parseSvg( const QString & svgFilename, QDataStream * out, const QString & path, int header ) { SVGXmlHandler handler( out, path, header ); QFile xmlFile( svgFilename ); QXmlInputSource inputSource(&xmlFile); QXmlSimpleReader reader; reader.setContentHandler(&handler); reader.parse( inputSource ); }
bool AliceHandler::readFile(const QString &fileName) { if ( !supportedAlice.isEmpty() ) cleanInfo(); QFile file(fileName); QXmlInputSource inputSource(&file); QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); return reader.parse(inputSource); }
void WebQueryPubMed::query( const QString& searchTerm, int numberOfResults ) { WebQuery::query( searchTerm, numberOfResults ); emit setTotalSteps( 2 ); QString term = searchTerm; KURL url = KURL( QString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%1&retmax=%2&tool=KBibTeX&[email protected]" ).arg( term.replace( "%", "%25" ).replace( " ", "+" ).replace( "?", "%3F" ).replace( "&", "%26" ) ).arg( numberOfResults ) ); QString tmpFile; if ( KIO::NetAccess::download( url, tmpFile, m_parent ) && !m_aborted ) { QFile inputFile( tmpFile ); QValueList<int> intList; QXmlInputSource inputSource( &inputFile ); QXmlSimpleReader reader; WebQueryPubMedStructureParserQuery handler( &intList ); reader.setContentHandler( &handler ); reader.parse( &inputSource ); inputFile.close(); KIO::NetAccess::removeTempFile( tmpFile ); emit setProgress( 1 ); QString ids; QValueList<int>::iterator it = intList.begin(); if ( it != intList.end() ) { ids.append( QString::number( *it ) ); ++it; for ( ; it != intList.end(); ++it ) { ids.append( "," ); ids.append( QString::number( *it ) ); } } url = KURL( QString( "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=%1&tool=KBibTeX&[email protected]" ).arg( ids ) ); if ( KIO::NetAccess::download( url, tmpFile, m_parent ) && !m_aborted ) { QFile inputFile( tmpFile ); QDomDocument doc( "efetch'ed" ); doc.setContent( &inputFile ); QDomElement docElem = doc.documentElement(); emit setProgress( 2 ); WebQueryPubMedResultParser resultParser; connect( &resultParser, SIGNAL( foundEntry( BibTeX::Entry* ) ), this, SIGNAL( foundEntry( BibTeX::Entry* ) ) ); resultParser.parse( doc.documentElement() ); inputFile.close(); KIO::NetAccess::removeTempFile( tmpFile ); emit endSearch( false ); }
void CPlist::initArray( QMainWindow * mWnd, QString &filename ) { QFile file( filename ); QXmlInputSource inputSource( &file ); QXmlSimpleReader reader; xmlReader handler( this ); reader.setContentHandler( &handler ); reader.setErrorHandler( &handler ); reader.parse( inputSource ); std::map< int, CCell* >::const_iterator it; for( it = arr.begin(); it != arr.end(); ++it ) { it->second->initButton( mWnd ); } }
void VCSlider::sendFeedBack(int value) { /* Send input feedback */ QLCInputSource src = inputSource(); if (src.isValid() == true) { if (invertedAppearance() == true) value = m_slider->maximum() - value; float fb = SCALE(float(value), float(m_slider->minimum()), float(m_slider->maximum()), float(0), float(UCHAR_MAX)); m_doc->outputMap()->feedBack(src.universe(), src.channel(), int(fb)); } }
LocationData CSDReader::link (DOMElement* element) throw(CSDReadException) { XMLURL uri(element->getAttribute(X("href"))); std::string name = Qedo::transcode(uri.getPath()); std::string::size_type pos = name.find_last_of("/"); if (pos != std::string::npos) { name.erase(0, pos + 1); } std::string fileName = path_ + name; LocationData data; data.uri = Qedo::transcode(element->getAttribute(X("href"))); data.file = name; // // get file // URLInputSource inputSource(uri); BinInputStream* inputStream = inputSource.makeStream(); if (!inputStream) { NORMAL_ERR2( "CSDReader: cannot find ", name ); throw CSDReadException(); } std::ofstream aFile; aFile.open(fileName.c_str(), std::ios::binary|std::ios::app); if (!aFile) { NORMAL_ERR2( "CSDReader: cannot open file ", fileName ); throw CSDReadException(); } unsigned char* buf = (unsigned char*)malloc(4096); unsigned int len = inputStream->readBytes(buf, 4096); while (len) { aFile.write((const char*)buf, len); len = inputStream->readBytes(buf, 4096); } free(buf); aFile.close(); return data; }
bool XSAppBuilder::compileObject(const QFileInfo &source) { if(source.suffix() == "xml") { qDebug()<<"xml"; QFile file(source.filePath()); QXmlInputSource inputSource(&file); QXmlSimpleReader reader; reader.setContentHandler(this); reader.setErrorHandler(this); return reader.parse(inputSource); } else if(source.suffix() == "json") { QFile file(source.filePath()); if(!file.open(QIODevice::ReadOnly)) { return false; } QString data = file.readAll(); file.close(); QJsonParseError jsonError; QJsonDocument jsonFile = QJsonDocument::fromJson(data.toUtf8(), &jsonError); if(jsonError.error == QJsonParseError::NoError) { if(jsonFile.isArray()) { QJsonArray jsonArray = jsonFile.array(); qDebug()<<"array: "<<jsonArray; } else if(jsonFile.isObject()) { QJsonObject jsonObj = jsonFile.object(); qDebug()<<"object: " << jsonObj; } return true; } else { qDebug()<<jsonError.errorString(); return false; } } return false; }
std::string CCDReader::link (DOMElement* element) throw(CCDReadException) { XMLURL uri(element->getAttribute(X("href"))); std::string name = Qedo::transcode(uri.getPath()); std::string::size_type pos = name.find_last_of("/"); if (pos != std::string::npos) { name.erase(0, pos + 1); } std::string fileName = path_ + name; URLInputSource inputSource(uri); BinInputStream* inputStream = inputSource.makeStream(); if (!inputStream) { throw CCDReadException(); } std::ofstream aFile; aFile.open(fileName.c_str(), std::ios::binary|std::ios::app); if (!aFile) { std::cerr << "Cannot open file " << fileName << std::endl; throw CCDReadException(); } unsigned char* buf = (unsigned char*)malloc(4096); unsigned int len = inputStream->readBytes(buf, 4096); while (len) { aFile.write((const char*)buf, len); len = inputStream->readBytes(buf, 4096); } free(buf); aFile.close(); return name; }
Components::Cookie* AssemblyFactoryImpl::create_assembly (const char* assembly_loc) throw (Components::Deployment::InvalidLocation, Components::CreateFailure) { DEBUG_OUT2( "AssemblyFactoryImpl: creating new assembly for ", assembly_loc ); // // exclusive // QedoLock lock(&mutex_); // // get path // XMLURL uri(assembly_loc); const XMLCh* p = uri.getPath(); if(!p) { NORMAL_ERR2( "AssemblyFactoryImpl: invalid assembly location: ", assembly_loc ); throw Components::Deployment::InvalidLocation(); } std::string name = Qedo::transcode(p); std::string::size_type pos = name.find_last_of("/"); if (pos != std::string::npos) { name.erase(0, pos + 1); } // // make input stream // URLInputSource inputSource(uri); BinInputStream* inputStream; try { inputStream = inputSource.makeStream(); } catch(...) { NORMAL_ERR2( "AssemblyFactoryImpl: invalid assembly location: ", assembly_loc ); throw Components::Deployment::InvalidLocation(); } if (!inputStream) { NORMAL_ERR2( "AssemblyFactoryImpl: invalid assembly location", assembly_loc ); throw Components::Deployment::InvalidLocation(); } // // create new cookie // Cookie_impl* new_cookie = new Cookie_impl(); const char * s = new_cookie->to_string(); std::string uuid = s; CORBA::string_free(const_cast<char*>(s)); // // store the package // std::string dir = getPath( packageDirectory_ ) + uuid; if( makeDir(dir) ) { NORMAL_ERR3( "AssemblyFactoryImpl: directory ", dir, " can not be created"); throw Components::CreateFailure(); } std::string package_name = getPath( dir ) + name; std::ofstream packageFile(package_name.c_str(), std::ios::binary|std::ios::app); if ( ! packageFile) { NORMAL_ERR2( "AssemblyFactoryImpl: cannot open file ", package_name ); throw Components::CreateFailure(); } unsigned char* buf = new unsigned char[4096]; unsigned int len = inputStream->readBytes(buf, 4096); while (len) { packageFile.write((const char*)buf, len); len = inputStream->readBytes(buf, 4096); } delete [] buf; packageFile.close(); delete inputStream; // // create new assembly // AssemblyImpl* ass = new AssemblyImpl(package_name, new_cookie, nameService_); assemblies_.push_back(ass); DEBUG_OUT( "..... done" ); return new_cookie; }
Q_DECL_EXPORT int main(int argc, char *argv[]) { QApplication app(argc, argv); // we can't read config in menaan contructor // because translator must be create and installed before widgets creating // so we read conf file there... qDebug()<<"[Application say:] Reading configuration"; ConfigData *configData; // read config data for application { QFile file(QApplication::applicationDirPath()+"/config.xml"); qDebug()<<"[Application say:] Check file"<<QApplication::applicationDirPath()+"/config.xml"; QXmlInputSource inputSource(&file); QXmlSimpleReader configReader; configData = new ConfigData(); ConfigHandler *configHandler = new ConfigHandler(configData); configReader.setContentHandler(configHandler); configReader.setErrorHandler(configHandler); configReader.parse(inputSource); delete configHandler; } // set translation qDebug()<<"[Application say:] Translation install"; QTranslator trans; int lg = configData->getLanguage(); switch (lg) { case ConfigData::English: trans.load(QApplication::applicationDirPath()+"/translations/en.qm"); break; case ConfigData::Russian: trans.load(QApplication::applicationDirPath()+"/translations/ru.qm"); break; case ConfigData::Germany: trans.load(QApplication::applicationDirPath()+"/translations/de.qm"); break; case ConfigData::French: trans.load(QApplication::applicationDirPath()+"/translations/fr.qm"); break; default: trans.load(QApplication::applicationDirPath()+"/translations/en.qm"); } app.installTranslator(&trans); Menaan * mainWidget = new Menaan(configData); Q_UNUSED(mainWidget) return app.exec(); }
// must be called with mLock held status_t AudioRecord::openRecord_l(size_t epoch) { status_t status; const sp<IAudioFlinger>& audioFlinger = AudioSystem::get_audio_flinger(); if (audioFlinger == 0) { ALOGE("Could not get audioflinger"); return NO_INIT; } IAudioFlinger::track_flags_t trackFlags = IAudioFlinger::TRACK_DEFAULT; pid_t tid = -1; // Client can only express a preference for FAST. Server will perform additional tests. // The only supported use case for FAST is callback transfer mode. if (mFlags & AUDIO_INPUT_FLAG_FAST) { if ((mTransfer != TRANSFER_CALLBACK) || (mAudioRecordThread == 0)) { ALOGW("AUDIO_INPUT_FLAG_FAST denied by client"); // once denied, do not request again if IAudioRecord is re-created mFlags = (audio_input_flags_t) (mFlags & ~AUDIO_INPUT_FLAG_FAST); } else { trackFlags |= IAudioFlinger::TRACK_FAST; tid = mAudioRecordThread->getTid(); } } mNotificationFramesAct = mNotificationFramesReq; if (!(mFlags & AUDIO_INPUT_FLAG_FAST)) { // Make sure that application is notified with sufficient margin before overrun if (mNotificationFramesAct == 0 || mNotificationFramesAct > mFrameCount/2) { mNotificationFramesAct = mFrameCount/2; } } audio_io_handle_t input = AudioSystem::getInput(mInputSource, mSampleRate, mFormat, mChannelMask, mSessionId); if (input == 0) { ALOGE("Could not get audio input for record source %d", mInputSource); return BAD_VALUE; } int originalSessionId = mSessionId; #ifdef QCOM_DIRECTTRACK if (inputSource() == AUDIO_SOURCE_VOICE_COMMUNICATION) { ALOGV("Notify use of Voice Communication"); trackFlags |= IAudioFlinger::TRACK_VOICE_COMMUNICATION; } #endif sp<IAudioRecord> record = audioFlinger->openRecord(input, mSampleRate, mFormat, mChannelMask, mFrameCount, &trackFlags, tid, &mSessionId, &status); ALOGE_IF(originalSessionId != 0 && mSessionId != originalSessionId, "session ID changed from %d to %d", originalSessionId, mSessionId); if (record == 0 || status != NO_ERROR) { ALOGE("AudioFlinger could not create record track, status: %d", status); AudioSystem::releaseInput(input); return status; } sp<IMemory> iMem = record->getCblk(); if (iMem == 0) { ALOGE("Could not get control block"); return NO_INIT; } void *iMemPointer = iMem->pointer(); if (iMemPointer == NULL) { ALOGE("Could not get control block pointer"); return NO_INIT; } if (mAudioRecord != 0) { mAudioRecord->asBinder()->unlinkToDeath(mDeathNotifier, this); mDeathNotifier.clear(); } mInput = input; mAudioRecord = record; mCblkMemory = iMem; audio_track_cblk_t* cblk = static_cast<audio_track_cblk_t*>(iMemPointer); mCblk = cblk; // FIXME missing fast track frameCount logic mAwaitBoost = false; if (mFlags & AUDIO_INPUT_FLAG_FAST) { if (trackFlags & IAudioFlinger::TRACK_FAST) { ALOGV("AUDIO_INPUT_FLAG_FAST successful; frameCount %u", mFrameCount); mAwaitBoost = true; // double-buffering is not required for fast tracks, due to tighter scheduling if (mNotificationFramesAct == 0 || mNotificationFramesAct > mFrameCount) { mNotificationFramesAct = mFrameCount; } } else { ALOGV("AUDIO_INPUT_FLAG_FAST denied by server; frameCount %u", mFrameCount); // once denied, do not request again if IAudioRecord is re-created mFlags = (audio_input_flags_t) (mFlags & ~AUDIO_INPUT_FLAG_FAST); if (mNotificationFramesAct == 0 || mNotificationFramesAct > mFrameCount/2) { mNotificationFramesAct = mFrameCount/2; } } } // starting address of buffers in shared memory void *buffers = (char*)cblk + sizeof(audio_track_cblk_t); // update proxy #ifdef QCOM_DIRECTTRACK mProxy = new AudioRecordClientProxy(cblk, buffers, mCblk->frameCount_, mFrameSize); #else mProxy = new AudioRecordClientProxy(cblk, buffers, mFrameCount, mFrameSize); #endif mProxy->setEpoch(epoch); mProxy->setMinimum(mNotificationFramesAct); mDeathNotifier = new DeathNotifier(this); mAudioRecord->asBinder()->linkToDeath(mDeathNotifier, this); return NO_ERROR; }
/** * Module initialization function. The initialization arguments string should * provide the path of a module configuration file that defines what files * are interesting. If the empty string is passed to this function, the module * assumes a default config file is present in the output directory. * * @param args Path of the configuration file that defines what files are * interesting, may be set to the empty string. * @return TskModule::OK on success, TskModule::FAIL otherwise. */ TSK_MODULE_EXPORT TskModule::Status initialize(const char* arguments) { TskModule::Status status = TskModule::OK; const std::string MSG_PREFIX = "InterestingFilesModule::initialize : "; try { // Make sure the file sets are cleared in case initialize() is called more than once. fileSets.clear(); configFilePath.assign(arguments); if (configFilePath.empty()) { // Use the default config file path. Poco::Path configurationFilePath(Poco::Path::forDirectory(GetSystemProperty(TskSystemProperties::MODULE_CONFIG_DIR))); configurationFilePath.pushDirectory(MODULE_NAME); configurationFilePath.setFileName(DEFAULT_CONFIG_FILE_NAME); configFilePath = configurationFilePath.toString(); } // Compile the contents of the config file into interesting file set definitions. Poco::File configFile = Poco::File(configFilePath); if (configFile.exists()) { std::ifstream configStream(configFile.path().c_str()); if (configStream) { Poco::XML::InputSource inputSource(configStream); Poco::AutoPtr<Poco::XML::Document> configDoc = Poco::XML::DOMParser().parse(&inputSource); Poco::XML::Element * rootElement = configDoc->documentElement(); if (rootElement == NULL) { std::ostringstream msg; msg << MSG_PREFIX << "Root element of config file is NULL."; throw TskException(msg.str()); } const std::string& ignoreKnownValue = Poco::XML::fromXMLString(rootElement->getAttribute(IGNORE_KNOWN_TAG)); if (!ignoreKnownValue.empty()) { knownType = parseKnownType(ignoreKnownValue); ignoreKnown = true; } Poco::AutoPtr<Poco::XML::NodeList> fileSetDefinitions = configDoc->getElementsByTagName(INTERESTING_FILE_SET_ELEMENT_TAG); for (unsigned long i = 0; i < fileSetDefinitions->length(); ++i) { compileInterestingFilesSet(fileSetDefinitions->item(i)); } } else { std::ostringstream msg; msg << MSG_PREFIX << "failed to open config file '" << configFilePath << "'"; throw TskException(msg.str()); } } else { std::ostringstream msg; msg << MSG_PREFIX << "config file'" << configFilePath << "' does not exist"; LOGERROR(msg.str()); } // Log the configuration. std::ostringstream msg; msg << MSG_PREFIX << "configured with " << fileSets.size() << " interesting file set definitions from '" << configFilePath << "'"; LOGINFO(msg.str()); } catch (TskException &ex) { status = TskModule::FAIL; configFilePath.clear(); std::ostringstream msg; msg << MSG_PREFIX << "TskException: " << ex.message(); LOGERROR(msg.str()); } catch (Poco::Exception &ex) { status = TskModule::FAIL; configFilePath.clear(); std::ostringstream msg; msg << MSG_PREFIX << "Poco::Exception: " << ex.displayText(); LOGERROR(msg.str()); } catch (std::exception &ex) { status = TskModule::FAIL; configFilePath.clear(); std::ostringstream msg; msg << MSG_PREFIX << "std::exception: " << ex.what(); LOGERROR(msg.str()); } catch (...) { status = TskModule::FAIL; configFilePath.clear(); LOGERROR(MSG_PREFIX + "unrecognized exception"); } return status; }