QVariant QSymSQLResult::data(int idx) { QVariant r; switch (d->stmt.ColumnType(idx)) { case ESqlBinary: { TPtrC8 data; d->stmt.ColumnBinary(idx, data); return QByteArray(reinterpret_cast<const char *>(data.Ptr()), data.Length()); break; } case ESqlInt: r = QVariant(d->stmt.ColumnInt(idx)); break; case ESqlInt64: r = QVariant(d->stmt.ColumnInt64(idx)); break; case ESqlReal: switch(numericalPrecisionPolicy()) { case QSql::LowPrecisionInt32: r = QVariant(d->stmt.ColumnInt(idx)); break; case QSql::LowPrecisionInt64: r = QVariant(d->stmt.ColumnInt64(idx)); break; case QSql::LowPrecisionDouble: r = QVariant(d->stmt.ColumnReal(idx)); break; case QSql::HighPrecision: default: TPtrC res; d->stmt.ColumnText(idx, res); r = QVariant(qt_TDesC2QString(res)); break; }; break; case ESqlNull: r = QVariant(QVariant::String); break; default: TPtrC res; d->stmt.ColumnText(idx, res); r = QVariant(qt_TDesC2QString(res)); break; } return r; }
SMFCredMgrErrorCode CSmfCredMgrClientSymbian::signMessageL(QString Message, QString Key, QString& Signature, SmfSignatureMethod AlgorithmUsed) { SMFCredMgrErrorCode signError = SmfErrNone; TPtr msgPtr((qt_QString2HBufC(Message))->Des()); TPtr keyPtr((qt_QString2HBufC(Key))->Des()); CSmfSignParameters* signMsgParams = CSmfSignParameters::NewL( msgPtr.Collapse(), keyPtr.Collapse()); CleanupStack::PushL(signMsgParams); CBufFlat* buf = CBufFlat::NewL(KMinBufSize); CleanupStack::PushL(buf); RBufWriteStream stream(*buf); CleanupClosePushL(stream); signMsgParams->ExternalizeL(stream); stream.CommitL(); TPtr8 bufPtr = buf->Ptr(0); TIpcArgs args; args.Set(0, &bufPtr); HBufC8* msgBuf = HBufC8::NewL(KMaxSignedMsgLength); TPtr8 msgBufPtr(msgBuf->Des()); CleanupStack::PushL(msgBuf); args.Set(1, &msgBufPtr); switch (AlgorithmUsed) { case ESMFRSAProtocol: { iSession.RequestService(ESmfRSASignMessage, args); } break; case ESMFHMACProtocol: { iSession.RequestService(ESmfHMACSHA1SignMessage, args); } break; default: { RDebug::Printf("Unsupported Algo:"); return SmfErrBadParameter; } } TBuf<KMaxSignedMsgLength> signedMsg; signedMsg.Copy(msgBufPtr); Signature = qt_TDesC2QString(signedMsg); CleanupStack::Pop(msgBuf); CleanupStack::PopAndDestroy(&stream); CleanupStack::PopAndDestroy(buf); CleanupStack::PopAndDestroy(signMsgParams); return signError; }
bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaData &metaData) { //1st time, lastError is result of dirHandle.Open(), entries.Count() is 0 and entryIndex is -1 so initial read is triggered //subsequent times, read is triggered each time we reach the end of the entry list //final time, lastError is KErrEof so we don't need to read anymore. ++entryIndex; if (lastError == KErrNone && entryIndex >= entries.Count()) { lastError = dirHandle.Read(entries); entryIndex = 0; } //each call to advance() gets the next entry from the entry list. //from the final (or only) read call, KErrEof is returned together with a full buffer so we still need to go through the list if ((lastError == KErrNone || lastError == KErrEof) && entryIndex < entries.Count()) { Q_ASSERT(entryIndex >= 0); const TEntry &entry(entries[entryIndex]); fileEntry = QFileSystemEntry(nativePath + qt_TDesC2QString(entry.iName), QFileSystemEntry::FromNativePath()); metaData.fillFromTEntry(entry); return true; } //TODO: error reporting, to allow user to distinguish empty directory from error condition. return false; }
QString QFileSystemEngine::homePath() { QString home = QDir::fromNativeSeparators(qt_TDesC2QString(PathInfo::PhoneMemoryRootPath())); if(home.endsWith(QLatin1Char('/'))) home.chop(1); return home; }
QString CSmfCredMgrClientSymbian::storeRSAKeysL(const QString KeyLabel, const QString keydata, const QDateTime Validity) { RDebug::Printf("Sending store RSA key message to server"); TPtrC labelPtr(qt_QString2TPtrC(KeyLabel)); TPtr dataPtr((qt_QString2HBufC(keydata)->Des())); QDateTime CurrentTime = QDateTime::currentDateTime(); TTimeIntervalSeconds duration(CurrentTime.secsTo(Validity)); TTime startDate; startDate.UniversalTime(); TTime endDate(startDate); endDate += duration; CSmfRsaKeyParameters* storeRSAKeysparams = CSmfRsaKeyParameters::NewL( labelPtr, startDate, endDate, (dataPtr.Collapse())); CleanupStack::PushL(storeRSAKeysparams); CBufFlat* buf = CBufFlat::NewL(KMinBufSize); CleanupStack::PushL(buf); RBufWriteStream stream(*buf); CleanupClosePushL(stream); storeRSAKeysparams->ExternalizeL(stream); stream.CommitL(); TPtr8 bufPtr = buf->Ptr(0); TIpcArgs args; args.Set(0, &bufPtr); CleanupStack::PopAndDestroy(&stream); HBufC8* retBuf = HBufC8::NewLC(KSHA1HashLengthBytes); TPtr8 retBufPtr(retBuf->Des()); args.Set(1, &retBufPtr); iSession.RequestService(ESmfStoreRSAKey, args); RDebug::Printf("SMF: Message completed"); TBuf<KSHA1HashLengthBytes> key; key.Copy(retBufPtr); QString RetString(qt_TDesC2QString(key)); CleanupStack::Pop(retBuf); CleanupStack::PopAndDestroy(buf); CleanupStack::PopAndDestroy(storeRSAKeysparams); RDebug::Printf("-In storeAuthDataL()"); return (RetString); }
/*! Opens the file descriptor specified by \a file in the mode given by \a openMode. Returns true on success; otherwise returns false. The \a handleFlags argument specifies whether the file handle will be closed by Qt. See the QFile::FileHandleFlags documentation for more information. */ bool QFSFileEngine::open(QIODevice::OpenMode openMode, const RFile &file, QFile::FileHandleFlags handleFlags) { Q_D(QFSFileEngine); // Append implies WriteOnly. if (openMode & QFile::Append) openMode |= QFile::WriteOnly; // WriteOnly implies Truncate if neither ReadOnly nor Append are sent. if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append))) openMode |= QFile::Truncate; d->openMode = openMode; d->lastFlushFailed = false; d->closeFileHandle = (handleFlags & QFile::AutoCloseHandle); d->fileEntry.clear(); d->fh = 0; d->fd = -1; d->tried_stat = 0; #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API //RFile64 adds only functions to RFile, no data members d->symbianFile = static_cast<const RFile64&>(file); #else d->symbianFile = file; #endif TInt ret; d->symbianFilePos = 0; if (openMode & QFile::Append) { // Seek to the end when in Append mode. ret = d->symbianFile.Size(d->symbianFilePos); } else { // Seek to current otherwise ret = d->symbianFile.Seek(ESeekCurrent, d->symbianFilePos); } if (ret != KErrNone) { setError(QFile::OpenError, QSystemError(ret, QSystemError::NativeError).toString()); d->openMode = QIODevice::NotOpen; #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API d->symbianFile = RFile64(); #else d->symbianFile = RFile(); #endif return false; } // Extract filename (best effort) TFileName fn; TInt err = d->symbianFile.FullName(fn); if (err == KErrNone) d->fileEntry = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath()); else d->fileEntry.clear(); return true; }
/*! Retrieves date format from Symbian locale and transforms it to Qt format. When \a short_format is true the method returns short date format. Otherwise it returns the long format. */ static QString symbianDateFormat(bool short_format) { TPtrC dateFormat; if (short_format) { dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); } else { dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); } return s60ToQtFormat(qt_TDesC2QString(dateFormat)); }
//static QFileSystemEntry QFileSystemEngine::currentPath() { TFileName fn; QFileSystemEntry ret; TInt r = qt_s60GetRFs().SessionPath(fn); if(r == KErrNone) { //remove terminating slash from non root paths (session path is clean, absolute and always ends in a \) if(fn.Length() > 3 && fn[fn.Length() - 1] == '\\') fn.SetLength(fn.Length() - 1); ret = QFileSystemEntry(qt_TDesC2QString(fn), QFileSystemEntry::FromNativePath()); } return ret; }
bool QSymSQLDriver::rollbackTransaction() { if (!isOpen() || isOpenError()) return false; TInt err = d->access.Exec(_L("ROLLBACK")); if (err < KErrNone) { setLastError(QSqlError(tr("Unable to rollback transaction"), qt_TDesC2QString(d->access.LastErrorMessage()), QSqlError::TransactionError, err)); return false; } return true; }
EXPORT_C QString localizedDirectoryName(QString& rawPath) { QString ret; std::exception dummy; // voodoo fix for "Undefined symbol typeinfo for std::exception" in armv5 build TRAPD(err, QT_TRYCATCH_LEAVING( CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL(); CleanupStack::PushL(localizer); localizer->SetFullPath(qt_QString2TPtrC(QDir::toNativeSeparators(rawPath))); if(localizer->IsLocalized()){ TPtrC locName(localizer->LocalizedName()); ret = qt_TDesC2QString(locName); } CleanupStack::PopAndDestroy(localizer); ) ) if (err != KErrNone)
QString QHostInfo::localHostName() { // Connect to ESOCK RSocketServ socketServ(qt_symbianGetSocketServer()); RHostResolver hostResolver; // RConnection not required to get the host name int err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp); if (err) return QString(); THostName hostName; err = hostResolver.GetHostName(hostName); if (err) return QString(); hostResolver.Close(); return qt_TDesC2QString(hostName); }
QString QDesktopServices::displayName(StandardLocation type) { QString ret; #ifdef Q_WS_S60 QString rawPath = storageLocation(type); TRAPD(err, QT_TRYCATCH_LEAVING( CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL(); CleanupStack::PushL(localizer); localizer->SetFullPath(qt_QString2TPtrC(QDir::toNativeSeparators(rawPath))); if (localizer->IsLocalized()) { TPtrC locName(localizer->LocalizedName()); ret = qt_TDesC2QString(locName); } CleanupStack::PopAndDestroy(localizer); ) ) if (err != KErrNone)
void readSymbianStoreLX(QMimeData* aData, CClipboard* clipboard) { // This function both leaves and throws exceptions. There must be no destructor // dependencies between cleanup styles, and no cleanup stack dependencies on stacked objects. CPlainText* text = CPlainText::NewL(); CleanupStack::PushL(text); TInt dataLength = text->PasteFromStoreL(clipboard->Store(), clipboard->StreamDictionary(), KPlainTextBegin); if (dataLength == 0) { User::Leave(KErrNotFound); } HBufC* hBuf = HBufC::NewL(dataLength); TPtr buf = hBuf->Des(); text->Extract(buf, KPlainTextBegin, dataLength); QString string = qt_TDesC2QString(buf); CleanupStack::PopAndDestroy(text); aData->clear(); aData->setText(string); }
void QSymSQLResultPrivate::initColumns(QSqlRecord& rec) { int nCols = stmt.ColumnCount(); if (nCols <= 0) { q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", "Error retrieving column count"), QSqlError::UnknownError, nCols)); return; } for (int i = 0; i < nCols; ++i) { TPtrC cName; TInt err = stmt.ColumnName(i, cName); if (err != KErrNone) { q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", "Error retrieving column name"), QSqlError::UnknownError, err)); return; } QString colName = qt_TDesC2QString(cName); // must use typeName for resolving the type to match QSymSQLDriver::record TPtrC tName; TSqlColumnType decColType; err = stmt.DeclaredColumnType(i, decColType); if (err != KErrNone) { q->setLastError(qMakeError(access, QCoreApplication::translate("QSymSQLResult", "Error retrieving column type"), QSqlError::UnknownError, err)); return; } int dotIdx = colName.lastIndexOf(QLatin1Char('.')); QSqlField fld(colName.mid(dotIdx == -1 ? 0 : dotIdx + 1), qGetColumnType(decColType)); rec.append(fld); } }
bool QTranslator::load(const QString & filename, const QString & directory, const QString & search_delimiters, const QString & suffix) { Q_D(QTranslator); d->clear(); QString fname = filename; QString prefix; if (QFileInfo(filename).isRelative()) { #ifdef Q_OS_SYMBIAN //TFindFile doesn't like path in the filename QString dir(directory); int slash = filename.lastIndexOf(QLatin1Char('/')); slash = qMax(slash, filename.lastIndexOf(QLatin1Char('\\'))); if (slash >=0) { //so move the path component into the directory prefix if (dir.isEmpty()) dir = filename.left(slash + 1); else dir = dir + QLatin1Char('/') + filename.left(slash + 1); fname = fname.mid(slash + 1); } if (dir.isEmpty()) prefix = QCoreApplication::applicationDirPath(); else prefix = QFileInfo(dir).absoluteFilePath(); //TFindFile doesn't like dirty paths if (prefix.length() > 2 && prefix.at(1) == QLatin1Char(':') && prefix.at(0).isLetter()) prefix[0] = QLatin1Char('Y'); #else prefix = directory; #endif if (prefix.length() && !prefix.endsWith(QLatin1Char('/'))) prefix += QLatin1Char('/'); } #ifdef Q_OS_SYMBIAN QString nativePrefix = QDir::toNativeSeparators(prefix); #endif QString realname; QString delims; delims = search_delimiters.isNull() ? QString::fromLatin1("_.") : search_delimiters; for (;;) { QFileInfo fi; #ifdef Q_OS_SYMBIAN //search for translations on other drives, e.g. Qt may be in Z, while app is in C //note this uses symbian search rules, i.e. y:->a:, followed by z: TFindFile finder(qt_s60GetRFs()); QString fname2 = fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); TInt err = finder.FindByDir( qt_QString2TPtrC(fname2), qt_QString2TPtrC(nativePrefix)); if (err != KErrNone) err = finder.FindByDir(qt_QString2TPtrC(fname), qt_QString2TPtrC(nativePrefix)); if (err == KErrNone) { fi.setFile(qt_TDesC2QString(finder.File())); realname = fi.canonicalFilePath(); if (fi.isReadable() && fi.isFile()) break; } #endif realname = prefix + fname + (suffix.isNull() ? QString::fromLatin1(".qm") : suffix); fi.setFile(realname); if (fi.isReadable() && fi.isFile()) break; realname = prefix + fname; fi.setFile(realname); if (fi.isReadable() && fi.isFile()) break; int rightmost = 0; for (int i = 0; i < (int)delims.length(); i++) { int k = fname.lastIndexOf(delims[i]); if (k > rightmost) rightmost = k; } // no truncations? fail if (rightmost == 0) return false; fname.truncate(rightmost); } // realname is now the fully qualified name of a readable file. return d->do_load(realname); }
*/ CEikAppUi *QS60MainDocument::CreateAppUiL() { // Create the application user interface, and return a pointer to it; // the framework takes ownership of this object return (static_cast <CEikAppUi*>(new(ELeave)QS60MainAppUi)); } /*! \internal */ CFileStore *QS60MainDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC &aFilename, RFs &/*aFs*/) { QT_TRYCATCH_LEAVING( { QCoreApplication* app = QCoreApplication::instance(); QString qname = qt_TDesC2QString(aFilename); QFileOpenEvent* event = new QFileOpenEvent(qname); app->postEvent(app, event); }) return 0; } /*! \internal */ void QS60MainDocument::OpenFileL(CFileStore *&aFileStore, RFile &aFile) { QT_TRYCATCH_LEAVING( { QCoreApplication* app = QCoreApplication::instance(); QFileOpenEvent* event = new QFileOpenEvent(aFile); app->postEvent(app, event);
/*! Retrieves time format from Symbian locale and transforms it to Qt format. */ static QString symbianTimeFormat() { return s60ToQtFormat(qt_TDesC2QString(ptrGetTimeFormatSpec(_s60Locale))); }
static QList<QNetworkInterfacePrivate *> interfaceListing() { TInt err(KErrNone); QList<QNetworkInterfacePrivate *> interfaces; // Connect to Native socket server RSocketServ socketServ; err = socketServ.Connect(); if (err) return interfaces; // Open dummy socket for interface queries RSocket socket; err = socket.Open(socketServ, _L("udp")); if (err) { socketServ.Close(); return interfaces; } // Ask socket to start enumerating interfaces err = socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl); if (err) { socket.Close(); socketServ.Close(); return interfaces; } int ifindex = 0; TPckgBuf<TSoInetInterfaceInfo> infoPckg; TSoInetInterfaceInfo &info = infoPckg(); while (socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, infoPckg) == KErrNone) { // Do not include IPv6 addresses because netmask and broadcast address cannot be determined correctly if (info.iName != KNullDesC && info.iAddress.IsV4Mapped()) { TName address; QNetworkAddressEntry entry; QNetworkInterfacePrivate *iface = 0; iface = new QNetworkInterfacePrivate; iface->index = ifindex++; interfaces << iface; iface->name = qt_TDesC2QString(info.iName); iface->flags = convertFlags(info); if (/*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec) { for (TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++) { address.AppendNumFixedWidth(info.iHwAddr[i], EHex, 2); if ((i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen()) address.Append(_L(":")); } address.UpperCase(); iface->hardwareAddress = qt_TDesC2QString(address); } // Get the address of the interface info.iAddress.Output(address); entry.setIp(QHostAddress(qt_TDesC2QString(address))); // Get the interface netmask // For some reason netmask is always 0.0.0.0 // info.iNetMask.Output(address); // entry.setNetmask( QHostAddress( qt_TDesC2QString( address ) ) ); // Workaround: Let Symbian determine netmask based on IP address class // TODO: Works only for IPv4 - Task: 259128 Implement IPv6 support TInetAddr netmask; netmask.NetMask(info.iAddress); netmask.Output(address); entry.setNetmask(QHostAddress(qt_TDesC2QString(address))); // Get the interface broadcast address if (iface->flags & QNetworkInterface::CanBroadcast) { // For some reason broadcast address is always 0.0.0.0 // info.iBrdAddr.Output(address); // entry.setBroadcast( QHostAddress( qt_TDesC2QString( address ) ) ); // Workaround: Let Symbian determine broadcast address based on IP address // TODO: Works only for IPv4 - Task: 259128 Implement IPv6 support TInetAddr broadcast; broadcast.NetBroadcast(info.iAddress); broadcast.Output(address); entry.setBroadcast(QHostAddress(qt_TDesC2QString(address))); } // Add new entry to interface address entries iface->addressEntries << entry; #if defined(QNETWORKINTERFACE_DEBUG) printf("\n Found network interface %s, interface flags:\n\ IsUp = %d, IsRunning = %d, CanBroadcast = %d,\n\ IsLoopBack = %d, IsPointToPoint = %d, CanMulticast = %d, \n\ ip = %s, netmask = %s, broadcast = %s,\n\ hwaddress = %s", iface->name.toLatin1().constData(), iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast, iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast, entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(), iface->hardwareAddress.toLatin1().constData()); #endif } }
static QList<QNetworkInterfacePrivate *> interfaceListing() { TInt err(KErrNone); QList<QNetworkInterfacePrivate *> interfaces; QList<QHostAddress> addressesWithEstimatedNetmasks; // Open dummy socket for interface queries RSocket socket; err = socket.Open(qt_symbianGetSocketServer(), _L("udp")); if (err) { return interfaces; } // Ask socket to start enumerating interfaces err = socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl); if (err) { socket.Close(); return interfaces; } int ifindex = 0; TPckgBuf<TSoInetInterfaceInfo> infoPckg; TSoInetInterfaceInfo &info = infoPckg(); while (socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, infoPckg) == KErrNone) { if (info.iName != KNullDesC) { TName address; QNetworkAddressEntry entry; QNetworkInterfacePrivate *iface = 0; iface = new QNetworkInterfacePrivate; iface->index = ifindex++; interfaces << iface; iface->name = qt_TDesC2QString(info.iName); iface->flags = convertFlags(info); if (/*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec) { for (TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++) { address.AppendNumFixedWidth(info.iHwAddr[i], EHex, 2); if ((i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen()) address.Append(_L(":")); } address.UpperCase(); iface->hardwareAddress = qt_TDesC2QString(address); } // Get the address of the interface entry.setIp(qt_QHostAddressFromTInetAddr(info.iAddress)); #if defined(QNETWORKINTERFACE_DEBUG) qDebug() << "address is" << info.iAddress.Family() << entry.ip(); qDebug() << "netmask is" << info.iNetMask.Family() << qt_QHostAddressFromTInetAddr( info.iNetMask ); #endif // Get the interface netmask if (info.iNetMask.IsUnspecified()) { // For some reason netmask is always 0.0.0.0 for IPv4 interfaces // and loopback interfaces (which we statically know) if (info.iAddress.IsV4Mapped()) { if (info.iFeatures & KIfIsLoopback) { entry.setPrefixLength(32); } else { // Workaround: Let Symbian determine netmask based on IP address class (IPv4 only API) TInetAddr netmask; netmask.NetMask(info.iAddress); entry.setNetmask(QHostAddress(netmask.Address())); //binary convert v4 address addressesWithEstimatedNetmasks << entry.ip(); #if defined(QNETWORKINTERFACE_DEBUG) qDebug() << "address class determined netmask" << entry.netmask(); #endif } } else { // For IPv6 interfaces if (info.iFeatures & KIfIsLoopback) { entry.setPrefixLength(128); } else if (info.iNetMask.IsUnspecified()) { //Don't see this error for IPv6, but try to handle it if it happens entry.setPrefixLength(64); //most common #if defined(QNETWORKINTERFACE_DEBUG) qDebug() << "total guess netmask" << entry.netmask(); #endif addressesWithEstimatedNetmasks << entry.ip(); } } } else { //Expected code path for IPv6 non loopback interfaces (IPv4 could come here if symbian is fixed) entry.setNetmask(qt_QHostAddressFromTInetAddr(info.iNetMask)); #if defined(QNETWORKINTERFACE_DEBUG) qDebug() << "reported netmask" << entry.netmask(); #endif } // broadcast address is determined from the netmask in postProcess() // Add new entry to interface address entries iface->addressEntries << entry; #if defined(QNETWORKINTERFACE_DEBUG) qDebug("\n Found network interface %s, interface flags:\n\ IsUp = %d, IsRunning = %d, CanBroadcast = %d,\n\ IsLoopBack = %d, IsPointToPoint = %d, CanMulticast = %d, \n\ ip = %s, netmask = %s, broadcast = %s,\n\ hwaddress = %s", iface->name.toLatin1().constData(), iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast, iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast, entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(), iface->hardwareAddress.toLatin1().constData()); #endif } }
QHostInfo QHostInfoAgent::fromName(const QString &hostName, QSharedPointer<QNetworkSession> networkSession) { QHostInfo results; // Connect to ESOCK RSocketServ socketServ(qt_symbianGetSocketServer()); RHostResolver hostResolver; int err; if (networkSession) err = QNetworkSessionPrivate::nativeOpenHostResolver(*networkSession, hostResolver, KAfInet, KProtocolInetUdp); else err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp); if (err) { setError_helper(results, err); return results; } TNameEntry nameResult; #if defined(QHOSTINFO_DEBUG) qDebug("QHostInfoAgent::fromName(%s) looking up...", hostName.toLatin1().constData()); #endif QHostAddress address; if (address.setAddress(hostName)) { // Reverse lookup #if defined(QHOSTINFO_DEBUG) qDebug("(reverse lookup)"); #endif TInetAddr IpAdd; IpAdd.Input(qt_QString2TPtrC(hostName)); // Synchronous request. nameResult returns Host Name. err = hostResolver.GetByAddress(IpAdd, nameResult); if (err) { //for behavioural compatibility with Qt 4.7 and unix/windows //backends: don't report error, return ip address as host name results.setHostName(address.toString()); } else { results.setHostName(qt_TDesC2QString(nameResult().iName)); } results.setAddresses(QList<QHostAddress>() << address); return results; } // IDN support QByteArray aceHostname = QUrl::toAce(hostName); results.setHostName(hostName); if (aceHostname.isEmpty()) { results.setError(QHostInfo::HostNotFound); results.setErrorString(hostName.isEmpty() ? QCoreApplication::translate("QHostInfoAgent", "No host name given") : QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); return results; } // Call RHostResolver::GetByAddress, and place all IPv4 addresses at the start and // the IPv6 addresses at the end of the address list in results. // Synchronous request. err = hostResolver.GetByName(qt_QString2TPtrC(QString::fromLatin1(aceHostname)), nameResult); if (err) { setError_helper(results, err); return results; } QList<QHostAddress> hostAddresses; TInetAddr hostAdd = nameResult().iAddr; if (!(nameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified())) hostAddresses.append(qt_QHostAddressFromTInetAddr(hostAdd)); // Check if there's more than one IP address linkd to this name while (hostResolver.Next(nameResult) == KErrNone) { hostAdd = nameResult().iAddr; // Ensure that record is valid (not an alias and with length greater than 0) if (!(nameResult().iFlags & TNameRecord::EAlias) && !(hostAdd.IsUnspecified())) hostAddresses.append(qt_QHostAddressFromTInetAddr(hostAdd)); } hostResolver.Close(); results.setAddresses(hostAddresses); return results; }