diff options
Diffstat (limited to 'src/corelib/kernel/qcore_unix.cpp')
-rw-r--r-- | src/corelib/kernel/qcore_unix.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index e4181b5c86..568453ec07 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -58,6 +58,10 @@ #include <mach/mach_time.h> #endif +#ifdef Q_OS_BLACKBERRY +#include <qsocketnotifier.h> +#endif // Q_OS_BLACKBERRY + QT_BEGIN_NAMESPACE static inline bool time_update(struct timespec *tv, const struct timespec &start, @@ -106,4 +110,43 @@ int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, } } +int qt_select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) +{ + if (timeout < 0) + return qt_safe_select(nfds, fdread, fdwrite, 0, 0); + + struct timespec tv; + tv.tv_sec = timeout / 1000; + tv.tv_nsec = (timeout % 1000) * 1000 * 1000; + return qt_safe_select(nfds, fdread, fdwrite, 0, &tv); +} + +#ifdef Q_OS_BLACKBERRY +// The BlackBerry event dispatcher uses bps_get_event. Unfortunately, already registered +// socket notifiers are disabled by a call to select. This is to rearm the standard streams. +int bb_select(QList<QSocketNotifier *> socketNotifiers, int nfds, fd_set *fdread, fd_set *fdwrite, + int timeout) +{ + QList<bool> socketNotifiersEnabled; + socketNotifiersEnabled.reserve(socketNotifiers.count()); + for (int a = 0; a < socketNotifiers.count(); ++a) { + if (socketNotifiers.at(a) && socketNotifiers.at(a)->isEnabled()) { + socketNotifiersEnabled.append(true); + socketNotifiers.at(a)->setEnabled(false); + } else { + socketNotifiersEnabled.append(false); + } + } + + const int ret = qt_select_msecs(nfds, fdread, fdwrite, timeout); + + for (int a = 0; a < socketNotifiers.count(); ++a) { + if (socketNotifiersEnabled.at(a) == true) + socketNotifiers.at(a)->setEnabled(true); + } + + return ret; +} +#endif // Q_OS_BLACKBERRY + QT_END_NAMESPACE |