45 #include "QtCore/qscopedpointer.h" 52 #include <private/qnetworksession_p.h> 65 Q_GLOBAL_STATIC(QSymbianHostInfoLookupManager, theHostInfoLookupManager)
159 #if defined QHOSTINFO_DEBUG 160 qDebug(
"QHostInfo::lookupHost(\"%s\", %p, %s)",
165 qWarning(
"QHostInfo::lookupHost() called with no event dispatcher");
169 qRegisterMetaType<QHostInfo>(
"QHostInfo");
215 QSymbianHostInfoLookupManager *manager = theHostInfoLookupManager();
219 if (manager->cache.isEnabled()) {
233 #ifndef QT_NO_BEARERMANAGEMENT 240 QSymbianHostResolver *symbianResolver = 0;
241 QT_TRAP_THROWING(symbianResolver =
new QSymbianHostResolver(name,
id, networkSession));
243 manager->scheduleLookup(symbianResolver);
257 theHostInfoLookupManager()->abortLookup(
id);
275 #if defined QHOSTINFO_DEBUG 285 #ifndef QT_NO_BEARERMANAGEMENT 288 #if defined QHOSTINFO_DEBUG 300 #ifndef QT_NO_BEARERMANAGEMENT 543 QMutableListIterator<QHostInfoRunnable*> iterator(manager->
postponedLookups);
544 while (iterator.hasNext()) {
616 while (iterator.hasNext()) {
620 bool alreadyRunning =
false;
623 alreadyRunning =
true;
627 if (!alreadyRunning) {
637 while (iterator.hasNext()) {
767 #ifdef QT_QHOSTINFO_CACHE_DISABLED_BY_DEFAULT 790 if (
cache.contains(name)) {
794 return element->
info;
816 cache.insert(name, element);
827 return theHostInfoLookupManager();
The QVariant class acts like a union for the most common Qt data types.
int lookupId() const
Returns the ID of this lookup.
static mach_timebase_info_data_t info
void qt_qhostinfo_clear_cache()
#define QT_END_NAMESPACE
This macro expands to.
void emitResultsReady(const QHostInfo &info)
The QMutex class provides access serialization between threads.
QList< QHostAddress > addrs
static QAbstractHostInfoLookupManager * globalInstance()
T * data() const
Returns the value of the pointer referenced by this object.
void setErrorString(const QString &errorString)
Sets the human readable description of the error that occurred to str if the lookup failed...
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
static void abortHostLookup(int lookupId)
Aborts the host lookup with the ID id, as returned by lookupHost().
void setAutoDelete(bool _autoDelete)
Enables auto-deletion if autoDelete is true; otherwise auto-deletion is disabled. ...
HostInfoError error() const
Returns the type of error that occurred if the host name lookup failed; otherwise returns NoError...
The QString class provides a Unicode character string.
void put(const QString &name, const QHostInfo &info)
The QObject class is the base class of all Qt objects.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
The QElapsedTimer class provides a fast way to calculate elapsed times.
QList< QHostAddress > addresses() const
Returns the list of IP addresses associated with hostName().
qint64 elapsed() const
Returns the number of milliseconds since this QElapsedTimer was last started.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
Q_CORE_EXPORT void qDebug(const char *,...)
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
void waitForThreadPoolDone()
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
void append(const T &t)
Inserts value at the end of the list.
QCache< QString, QHostInfoCacheElement > cache
#define QT_BEGIN_NAMESPACE
This macro expands to.
QList< int > abortedLookups
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
void setHostName(const QString &name)
Sets the host name of this QHostInfo to hostName.
void waitForDone()
Waits for each thread to exit and removes all threads from the thread pool.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setAddresses(const QList< QHostAddress > &addresses)
Sets the list of addresses in this QHostInfo to addresses.
QString hostName() const
Returns the name of the host whose IP addresses were looked up.
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
void prepend(const T &t)
Inserts value at the beginning of the list.
const T & at(int i) const
Returns the item at index position i in the list.
void start(QRunnable *runnable, int priority=0)
Reserves a thread and uses it to run runnable, unless this thread will make the current thread count ...
Q_CORE_EXPORT void qWarning(const char *,...)
QHostInfo::HostInfoError err
void Q_AUTOTEST_EXPORT qt_qhostinfo_enable_cache(bool e)
static const char * data(const QByteArray &arr)
The QHostInfo class provides static functions for host name lookups.
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
void clear()
Removes all items from the list.
static QHostInfo fromName(const QString &hostName, QSharedPointer< QNetworkSession > networkSession)
void setError(HostInfoError error)
Sets the error type of this QHostInfo to error.
QList< QHostInfoRunnable * > currentLookups
T * data() const
Returns the value of the pointer referenced by this object.
const char * constData() const
Returns a pointer to the data stored in the byte array.
void scheduleLookup(QHostInfoRunnable *r)
void enqueue(const T &t)
Adds value t to the tail of the queue.
QScopedPointer< QHostInfoPrivate > d
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
static QHostInfo fromName(const QString &name)
Looks up the IP address(es) for the given host name.
QHostInfoRunnable(QString hn, int i)
static QThread * mainThread()
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
QHostInfo & operator=(const QHostInfo &d)
Assigns the data of the other object to this host info object, and returns a reference to it...
~QHostInfo()
Destroys the host info object.
int length() const
This function is identical to count().
QHostInfo(int lookupId=-1)
Constructs an empty host info object with lookup ID id.
int size() const
Returns the number of items in the list.
static int lookupHost(const QString &name, QObject *receiver, const char *member)
Looks up the IP address(es) associated with host name name, and returns an ID for the lookup...
int maxThreadCount
This property represents the maximum number of threads used by the thread pool.
int fetchAndAddRelaxed(int valueToAdd)
void run()
Implement this pure virtual function in your subclass.
#define Q_AUTOTEST_EXPORT
QHostInfoResult resultEmitter
T qvariant_cast(const QVariant &)
T takeAt(int i)
Removes the item at index position i and returns it.
static QBasicAtomicInt theIdCounter
QString errorString() const
If the lookup failed, this function returns a human readable description of the error; otherwise "Unk...
QVariant property(const char *name) const
Returns the value of the object's name property.
HostInfoError
This enum describes the various errors that can occur when trying to resolve a host name...
QList< QHostInfoRunnable * > finishedLookups
static QHostInfo fromName(const QString &hostName)
void lookupFinished(QHostInfoRunnable *r)
QQueue< QHostInfoRunnable * > scheduledLookups
QHostInfo get(const QString &name, bool *valid)
void setMaxThreadCount(int maxThreadCount)
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
QList< QHostInfoRunnable * > postponedLookups
void start()
Starts this timer.
void setLookupId(int id)
Sets the ID of this lookup to id.
~QHostInfoLookupManager()
QHostInfo qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id)
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.