void ServerLogger::startLog(const QString &logFileName) { if (!logFileName.isEmpty()) { QFileInfo fi(logFileName); QDir fileDir(fi.path()); if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) { std::cerr << "ERROR: logfile folder doesn't exist and i can't create it." << std::endl; logFile = 0; return; } logFile = new QFile(logFileName, this); if(!logFile->open(QIODevice::Append)) { std::cerr << "ERROR: can't open() logfile." << std::endl; delete logFile; logFile = 0; return; } #ifdef Q_OS_UNIX ::socketpair(AF_UNIX, SOCK_STREAM, 0, sigHupFD); snHup = new QSocketNotifier(sigHupFD[1], QSocketNotifier::Read, this); connect(snHup, SIGNAL(activated(int)), this, SLOT(handleSigHup())); #endif } else
//--------------------------------------------------------------- // CNativeMmsUtility::getAttachmentListFromSmilL // @see header //--------------------------------------------------------------- void CNativeMmsUtility::getAttachmentListFromSmilL( ConvergedMessageAttachmentList& attachmentlist) { #ifdef _DEBUG_TRACES_ qDebug() << " Enter CNativeMmsUtility::getAttachmentListFromSmilL"; #endif //reset the reader to the root of the DOM tree ireader->reset(); //begin traversal while (!ireader->atEndL()) { CMDXMLNode* node = ireader->nextNodeL(); if (node->NodeType() == CMDXMLNode::EElementNode && (node->NodeName().CompareF(KImageTag) == 0 || node->NodeName().CompareF(KAudioTag) == 0 || node->NodeName().CompareF(KVideoTag) == 0 || node->NodeName().CompareF(KTextTag) == 0)) { CMDXMLElement* el = static_cast<CMDXMLElement*> (node); TPtrC attrvalptr; if (KErrNone == el->GetAttribute(KSrcAttr, attrvalptr)) { //resolve content-id QString filepath = getByUrlL(attrvalptr); if (filepath.isEmpty()) { //get smil's containing dir //because media source is relative to it. QString smildirpath = fileDir(ismilfilepath); QString mfilename = XQConversions::s60DescToQString(attrvalptr); filepath = smildirpath.append(mfilename); } // converting directory separators from native to // universal (QT) format filepath.replace(KBackwardSlash, KForwardSlash); ConvergedMessageAttachment * att = new ConvergedMessageAttachment(filepath, ConvergedMessageAttachment::EInline); attachmentlist << att; } } } #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::getAttachmentListFromSmilL"; #endif }
bool SaveTokensPage::validatePage() { bool ok = false; const QString dataDir = #if QT_VERSION < 0x050000 QDesktopServices::storageLocation(QDesktopServices::DataLocation); #else QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); #endif QSettings* settings = new QSettings(this); QString defaultPath = settings->value("paths/tokendatabase").toString(); QString windowName = tr("Save token database"); QString fileType = tr("XML; token database (*.xml)"); do { QString fileName; if (defaultPath.isEmpty()) { if (defaultPathCheckBox->isChecked()) fileName = dataDir + "/tokens.xml"; else fileName = QFileDialog::getSaveFileName(this, windowName, dataDir + "/tokens.xml", fileType); settings->setValue("paths/tokendatabase", fileName); } else { if (defaultPathCheckBox->isChecked()) fileName = defaultPath; else fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType); } if (fileName.isEmpty()) { return false; } QFileInfo fi(fileName); QDir fileDir(fi.path()); if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) { return false; } if (wizard()->saveTokensToFile(fileName)) { ok = true; QMessageBox::information(this, tr("Success"), tr("The token database has been saved successfully to\n%1").arg(fileName)); } else { QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));; if (defaultPathCheckBox->isChecked()) defaultPathCheckBox->setChecked(false); } } while (!ok); return true; }
QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, const QPointF &position, QmlItemNode parentNode) { if (!parentNode.isValid()) parentNode = rootQmlItemNode(); if (!parentNode.isValid()) return QmlItemNode(); QmlItemNode newNode; RewriterTransaction transaction = beginRewriterTransaction(); { QList<QPair<QString, QVariant> > propertyPairList; propertyPairList.append(qMakePair(QString("x"), QVariant( round(position.x(), 4)))); propertyPairList.append(qMakePair(QString("y"), QVariant( round(position.y(), 4)))); QString relativeImageName = imageName; //use relative path if (QFileInfo(model()->fileUrl().toLocalFile()).exists()) { QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath()); relativeImageName = fileDir.relativeFilePath(imageName); } propertyPairList.append(qMakePair(QString("source"), QVariant(relativeImageName))); newNode = createQmlItemNode("Qt/Image",4, 7, propertyPairList); parentNode.nodeAbstractProperty("data").reparentHere(newNode); Q_ASSERT(newNode.isValid()); QString id; int i = 1; QString name("image"); name.remove(QLatin1Char(' ')); do { id = name + QString::number(i); i++; } while (hasId(id)); //If the name already exists count upwards newNode.setId(id); if (!currentState().isBaseState()) { newNode.modelNode().variantProperty("opacity") = 0; newNode.setVariantProperty("opacity", 1); } Q_ASSERT(newNode.isValid()); } Q_ASSERT(newNode.isValid()); return newNode; }
bool SaveTokensPage::validatePage() { bool ok = false; QString defaultPath = settingsCache->getTokenDatabasePath(); QString windowName = tr("Save token database"); QString fileType = tr("XML; token database (*.xml)"); do { QString fileName; if (defaultPathCheckBox->isChecked()) { fileName = defaultPath; } else { fileName = QFileDialog::getSaveFileName(this, windowName, defaultPath, fileType); } if (fileName.isEmpty()) { return false; } QFileInfo fi(fileName); QDir fileDir(fi.path()); if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) { return false; } if (wizard()->saveTokensToFile(fileName)) { ok = true; QMessageBox::information(this, tr("Success"), tr("The token database has been saved successfully to\n%1").arg(fileName)); } else { QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));; if (defaultPathCheckBox->isChecked()) { defaultPathCheckBox->setChecked(false); } } } while (!ok); return true; }
//--------------------------------------------------------------- // CNativeMmsUtility::getBodyTextFromSmilL // @see header //--------------------------------------------------------------- void CNativeMmsUtility::getBodyTextFromSmilL(QString& returnbuf) { #ifdef _DEBUG_TRACES_ qDebug() << " Enter CNativeMmsUtility::getBodyTextFromSmilL"; #endif TPtrC attrvalptr; //reset the reader to the root of the DOM tree ireader->reset(); //begin traversal while (!ireader->atEndL()) { CMDXMLNode* node = ireader->nextNodeL(); if (node->NodeType() == CMDXMLNode::EElementNode && node->NodeName().CompareF(KTextTag) == 0) { CMDXMLElement* el = static_cast<CMDXMLElement*> (node); if (KErrNone == el->GetAttribute(KSrcAttr, attrvalptr)) { QString filepath = getByUrlL(attrvalptr); if (filepath.isEmpty()) { //get smil's containing dir //because media source is relative to it. QString smildirpath = fileDir(ismilfilepath); QString mfilename = XQConversions::s60DescToQString(attrvalptr); filepath = smildirpath.append(mfilename); } readFileIntoBuffer(filepath, returnbuf); break; } } } #ifdef _DEBUG_TRACES_ qDebug() << " Exit CNativeMmsUtility::getBodyTextFromSmilL"; #endif return; }
FileManager::FileManager(QObject *parent) : QObject(parent), m_fileOpThread(0) { QString dataDir = QStandardPaths::standardLocations( QStandardPaths::DataLocation).at(0); #ifdef Q_OS_WIN dataDir.replace("\\", "/"); #endif // Q_OS_WIN if (!QDir(dataDir).exists()) { QDir::current().mkpath(dataDir); } m_fileDirPath = dataDir + "/files/"; //create file dir if not present QDir fileDir(m_fileDirPath); if (!fileDir.exists()) { QDir::current().mkpath(m_fileDirPath); } m_metadataEngine = &MetadataEngine::getInstance(); m_settingsManager = new SettingsManager; }
const INT32 _dpsLogFilter::getFileCount( const CHAR *path ) { INT32 fileCount = 0 ; const CHAR *pFileName = "sequoiadbLog." ; fs::path fileDir( path ) ; fs::directory_iterator endIter ; for( fs::directory_iterator it( path ); it != endIter; ++it ) { const CHAR *filepath = it->path().filename().string().c_str() ; const CHAR *dotPos = ossStrrchr( filepath, '.' ) ; if( !dotPos ) continue ; const CHAR *namePos = ossStrstr( filepath, pFileName ) ; if( !namePos ) continue ; if( ( dotPos - namePos + 1 ) != (UINT32)ossStrlen( pFileName ) ) continue ; ++fileCount ; } return fileCount ; }
QmlItemNode QmlModelView::createQmlItemNodeFromImage(const QString &imageName, const QPointF &position, QmlItemNode parentNode) { if (!parentNode.isValid()) parentNode = rootQmlItemNode(); if (!parentNode.isValid()) return QmlItemNode(); QmlItemNode newNode; RewriterTransaction transaction = beginRewriterTransaction(); { const QString newImportUrl = QLatin1String("QtQuick"); const QString newImportVersion = QLatin1String("1.0"); Import newImport = Import::createLibraryImport(newImportUrl, newImportVersion); foreach (const Import &import, model()->imports()) { if (import.isLibraryImport() && import.url() == newImport.url() && import.version() == newImport.version()) { // reuse this import newImport = import; break; } } if (!model()->imports().contains(newImport)) { model()->changeImports(QList<Import>() << newImport, QList<Import>()); } QList<QPair<QString, QVariant> > propertyPairList; propertyPairList.append(qMakePair(QString("x"), QVariant( round(position.x(), 4)))); propertyPairList.append(qMakePair(QString("y"), QVariant( round(position.y(), 4)))); QString relativeImageName = imageName; //use relative path if (QFileInfo(model()->fileUrl().toLocalFile()).exists()) { QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath()); relativeImageName = fileDir.relativeFilePath(imageName); } propertyPairList.append(qMakePair(QString("source"), QVariant(relativeImageName))); newNode = createQmlItemNode("QtQuick.Image", 1, 0, propertyPairList); parentNode.nodeAbstractProperty("data").reparentHere(newNode); Q_ASSERT(newNode.isValid()); QString id; int i = 1; QString name("image"); name.remove(QLatin1Char(' ')); do { id = name + QString::number(i); i++; } while (hasId(id)); //If the name already exists count upwards newNode.setId(id); if (!currentState().isBaseState()) { newNode.modelNode().variantProperty("opacity") = 0; newNode.setVariantProperty("opacity", 1); } Q_ASSERT(newNode.isValid()); } Q_ASSERT(newNode.isValid()); return newNode; }
void PropertyEditorView::changeValue(const QString &name) { PropertyName propertyName = name.toUtf8(); if (propertyName.isNull()) return; if (m_locked) return; if (propertyName == "type") return; if (!m_selectedNode.isValid()) return; if (propertyName == "id") { PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(propertyName); const QString newId = value->value().toString(); if (newId == m_selectedNode.id()) return; if (m_selectedNode.isValidId(newId) && !hasId(newId)) { m_selectedNode.setIdWithRefactoring(newId); } else { m_locked = true; value->setValue(m_selectedNode.id()); m_locked = false; if (!m_selectedNode.isValidId(newId)) Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId)); else Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 already exists.").arg(newId)); } return; } PropertyName underscoreName(propertyName); underscoreName.replace('.', '_'); PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(underscoreName); if (value ==0) return; QmlObjectNode qmlObjectNode(m_selectedNode); QVariant castedValue; if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) { castedValue = qmlObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value()); } else if (propertyIsAttachedLayoutProperty(propertyName)) { castedValue = value->value(); } else { qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)"; return ; } if (value->value().isValid() && !castedValue.isValid()) { qWarning() << "PropertyEditor:" << propertyName << "not properly casted (metainfo)"; return ; } if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "QUrl" || qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "url") { //turn absolute local file paths into relative paths QString filePath = castedValue.toUrl().toString(); if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) { QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath()); castedValue = QUrl(fileDir.relativeFilePath(filePath)); } } if (castedValue.type() == QVariant::Color) { QColor color = castedValue.value<QColor>(); QColor newColor = QColor(color.name()); newColor.setAlpha(color.alpha()); castedValue = QVariant(newColor); } try { if (!value->value().isValid()) { //reset qmlObjectNode.removeProperty(propertyName); } else { if (castedValue.isValid() && !castedValue.isNull()) { m_locked = true; qmlObjectNode.setVariantProperty(propertyName, castedValue); m_locked = false; } } } catch (const RewritingException &e) { e.showException(); } }
INT32 _dpsLogFilter::doParse() { INT32 rc = SDB_OK ; BOOLEAN Open = FALSE ; CHAR dstFile[ OSS_MAX_PATHSIZE + 1 ] = { 0 } ; OSSFILE fileFrom, fileTo ; if( isDir( _cmdData->dstPath ) ) { INT32 len = ossStrlen( _cmdData->dstPath ) ; if ( OSS_FILE_SEP_CHAR == _cmdData->dstPath[ len - 1 ] ) { ossSnprintf( dstFile, OSS_MAX_PATHSIZE, "%s%s", _cmdData->dstPath, "tmpLog.log" ) ; } else { ossSnprintf( dstFile, OSS_MAX_PATHSIZE, "%s"OSS_FILE_SEP"%s", _cmdData->dstPath, "tmpLog.log" ) ; } } else { ossSnprintf( dstFile, OSS_MAX_PATHSIZE, "%s", _cmdData->dstPath ) ; } if( !_cmdData->output ) { rc = ossOpen( dstFile, OSS_REPLACE | OSS_READWRITE, OSS_RU | OSS_WU | OSS_RG, fileTo ) ; if( rc ) { printf( "Unable to open file: %s\n", dstFile ) ; goto error ; } Open = TRUE ; } if ( SDB_LOG_FILTER_META == _filter->getType() ) { rc = _filter->doFilte( _cmdData, fileTo, NULL ) ; if( rc ) { goto error ; } goto done ; } if( isDir( _cmdData->srcPath ) ) { if( SDB_LOG_FILTER_LAST == _filter->getType() ) { printf( "Error: Cannot specify a dir path when using --last/-e\n" ); rc = SDB_INVALIDARG ; goto error ; } INT32 const MAX_FILE_COUNT = getFileCount( _cmdData->srcPath ) ; if( 0 >= MAX_FILE_COUNT ) { printf( "Cannot find any Log files\nPlease check" " and input the correct log file path\n" ) ; rc = SDB_INVALIDPATH ; goto error ; } for( INT32 idx = 0 ; idx < MAX_FILE_COUNT ; ++idx ) { fs::path fileDir( _cmdData->srcPath ) ; const CHAR *filepath = fileDir.string().c_str() ; CHAR filename[ OSS_MAX_PATHSIZE * 2 ] = { 0 } ; ossSnprintf( filename, OSS_MAX_PATHSIZE, "%s/sequoiadbLog.%d", filepath, idx ) ; if( !isFileExisted( filename ) ) { rc = SDB_INVALIDPATH ; goto error ; } rc = _filter->doFilte( _cmdData, fileTo, filename ) ; if( rc && idx != MAX_FILE_COUNT - 1 ) { rc = SDB_OK ; continue ; } } } else { if( !isFileExisted( _cmdData->srcPath ) ) { rc = SDB_INVALIDPATH ; goto error ; } rc = _filter->doFilte( _cmdData, fileTo, _cmdData->srcPath ) ; if( rc ) { goto error ; } } done: if( Open ) { ossClose( fileTo ) ; } return rc ; error: goto done ; }
void PropertyEditorView::changeValue(const QString &name) { PropertyName propertyName = name.toUtf8(); if (propertyName.isNull()) return; if (m_locked) return; if (propertyName == "type") return; if (!m_selectedNode.isValid()) return; if (propertyName == "id") { PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(propertyName); const QString newId = value->value().toString(); if (newId == m_selectedNode.id()) return; if (m_selectedNode.isValidId(newId) && !modelNodeForId(newId).isValid() ) { if (m_selectedNode.id().isEmpty() || newId.isEmpty()) { //no id try { m_selectedNode.setId(newId); } catch (InvalidIdException &e) { //better save then sorry m_locked = true; value->setValue(m_selectedNode.id()); m_locked = false; QMessageBox::warning(0, tr("Invalid Id"), e.description()); } } else { //there is already an id, so we refactor if (rewriterView()) rewriterView()->renameId(m_selectedNode.id(), newId); } } else { m_locked = true; value->setValue(m_selectedNode.id()); m_locked = false; if (!m_selectedNode.isValidId(newId)) QMessageBox::warning(0, tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId)); else QMessageBox::warning(0, tr("Invalid Id"), tr("%1 already exists.").arg(newId)); } return; } //.replace(QLatin1Char('.'), QLatin1Char('_')) PropertyName underscoreName(propertyName); underscoreName.replace('.', '_'); PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(underscoreName); if (value ==0) return; QmlObjectNode qmlObjectNode(m_selectedNode); QVariant castedValue; if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) { castedValue = qmlObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value()); } else { qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)"; return ; } if (value->value().isValid() && !castedValue.isValid()) { qWarning() << "PropertyEditor:" << propertyName << "not properly casted (metainfo)"; return ; } if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "QUrl" || qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "url") { //turn absolute local file paths into relative paths QString filePath = castedValue.toUrl().toString(); if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) { QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath()); castedValue = QUrl(fileDir.relativeFilePath(filePath)); } } if (castedValue.type() == QVariant::Color) { QColor color = castedValue.value<QColor>(); QColor newColor = QColor(color.name()); newColor.setAlpha(color.alpha()); castedValue = QVariant(newColor); } try { if (!value->value().isValid()) { //reset qmlObjectNode.removeProperty(propertyName); } else { if (castedValue.isValid() && !castedValue.isNull()) { m_locked = true; qmlObjectNode.setVariantProperty(propertyName, castedValue); m_locked = false; } } } catch (RewritingException &e) { QMessageBox::warning(0, "Error", e.description()); } }