summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-05-22 12:32:27 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-05-22 12:32:27 (GMT)
commitd001cef792b2f41615cb1f7657bed3d7525ffb0e (patch)
tree03ec9dc4a9a870d2b8902083d56431d8b4b54217
parenta0fb8f874d0b8b8db5f50706a432bdb5a0294bf0 (diff)
parent1cfb5bcaa2cab142479ee975e25d9f605f852dad (diff)
downloadQt-d001cef792b2f41615cb1f7657bed3d7525ffb0e.zip
Qt-d001cef792b2f41615cb1f7657bed3d7525ffb0e.tar.gz
Qt-d001cef792b2f41615cb1f7657bed3d7525ffb0e.tar.bz2
Merge branch '4.5'
-rwxr-xr-xconfigure4
-rw-r--r--dist/changes-4.5.24
-rw-r--r--src/3rdparty/webkit/VERSION2
-rw-r--r--src/3rdparty/webkit/WebCore/ChangeLog39
-rw-r--r--src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp1
-rw-r--r--src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp4
-rw-r--r--src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp8
-rw-r--r--src/3rdparty/webkit/WebKit/qt/ChangeLog14
-rw-r--r--src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp8
-rw-r--r--src/corelib/io/qprocess_unix.cpp23
-rw-r--r--src/gui/painting/qtransform.h14
-rw-r--r--src/gui/styles/gtksymbols.cpp27
-rw-r--r--src/gui/styles/qcommonstyle.cpp2
-rw-r--r--src/gui/text/qfontengine_mac.mm4
-rw-r--r--src/gui/text/qtextengine.cpp40
-rw-r--r--src/network/socket/qnativesocketengine_p.h9
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp61
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp2
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp3
-rw-r--r--src/sql/drivers/oci/qsql_oci.cpp12
-rw-r--r--tests/auto/_networkselftest/_networkselftest.pro6
-rw-r--r--tests/auto/_networkselftest/tst_networkselftest.cpp592
-rw-r--r--tests/auto/auto.pro3
23 files changed, 758 insertions, 124 deletions
diff --git a/configure b/configure
index 740f95a..b57e8cb 100755
--- a/configure
+++ b/configure
@@ -202,7 +202,7 @@ earlyArgParse()
VAL=$1
fi
;;
- h|help|--help|-help)
+ -h|help|--help|-help)
if [ "$VAL" = "yes" ]; then
OPT_HELP="$VAL"
COMMERCIAL_USER="no" #doesn't matter we will display the help
@@ -2718,7 +2718,7 @@ if [ "$PLATFORM_MAC" = "yes" ]; then
# Build commmand line arguments we can pass to the compiler during configure tests
# by prefixing each arch with "-arch".
CFG_MAC_ARCHS_GCC_FORMAT="${CFG_MAC_ARCHS/x86/i386}"
- CFG_MAC_ARCHS_GCC_FORMAT="${CFG_MAC_ARCHS/i386_64/x86_64}"
+ CFG_MAC_ARCHS_GCC_FORMAT="${CFG_MAC_ARCHS_GCC_FORMAT/i386_64/x86_64}"
for ARCH in $CFG_MAC_ARCHS_GCC_FORMAT; do
MAC_ARCHS_COMMANDLINE="$MAC_ARCHS_COMMANDLINE -arch $ARCH"
done
diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2
index b3e808f..1e00208 100644
--- a/dist/changes-4.5.2
+++ b/dist/changes-4.5.2
@@ -42,8 +42,8 @@ Third party components
Memory (r41527, r43764, r43828, r43830)
JavaScript (r39882, r40086, r40131, r40133)
Rendering (r41285, r41296, r41659, r42887)
- Network (r41664, r42516)
- Plugins (r41346, r43550)
+ Network (r41664, r42516, r42747)
+ Plugins (r41346, r43550, r43915, r43917, r43923)
Clipboard (r41360)
****************************************************************************
diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION
index 7adbd6f..7d5d1c5 100644
--- a/src/3rdparty/webkit/VERSION
+++ b/src/3rdparty/webkit/VERSION
@@ -8,4 +8,4 @@ The commit imported was from the
and has the sha1 checksum
- 40b523e9eaaba38c182e5a9c319f0069ebf98330
+ 4ee8af9348b3f57d3c0f3575ae0a58336cf07a92
diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog
index a4cb62d..072beee 100644
--- a/src/3rdparty/webkit/WebCore/ChangeLog
+++ b/src/3rdparty/webkit/WebCore/ChangeLog
@@ -1,3 +1,42 @@
+2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Do not call the parent implementation (Widget::) in show() and hide()
+ of the PluginViewQt, as it always changes the visible state of the
+ platformWidget (equal to the platformPluginWidget in the Qt port),
+ thus ignoring the isParentVisible() test.
+
+ * plugins/qt/PluginViewQt.cpp:
+ (WebCore::PluginView::show):
+ (WebCore::PluginView::hide):
+
+2009-04-22 Tamas Szirbucz <szirbucz.tamas@stud.u-szeged.hu>
+
+ Reviewed by Ariya Hidayat.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25023
+ Delete reply in QNetworkReplyHandler::abort() to avoid leak.
+
+ * platform/network/qt/QNetworkReplyHandler.cpp:
+ (WebCore::QNetworkReplyHandler::abort):
+
+2009-05-20 Holger Hans Peter Freyther <zecke@selfish.org>
+
+ Reviewed by Anders Carlsson.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24510
+
+ Fix a bug where the browserfuncs were not properly assigned,
+ make hasproperty use _NP_HasProperty and hasmethod _NP_HasMethod.
+
+ Test: plugins/netscape-invoke-browserfuncs.html
+
+ * plugins/gtk/PluginPackageGtk.cpp:
+ (WebCore::PluginPackage::load): Fix assignment
+ * plugins/qt/PluginPackageQt.cpp:
+ (WebCore::PluginPackage::load): Fix assignment
+
2009-05-11 Yael Aharon <yael.aharon@nokia.com>
Reviewed by Holger Freyther.
diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
index 2c730a6..3e9b239 100644
--- a/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
+++ b/src/3rdparty/webkit/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
@@ -174,6 +174,7 @@ void QNetworkReplyHandler::abort()
if (m_reply) {
QNetworkReply* reply = release();
reply->abort();
+ reply->deleteLater();
deleteLater();
}
}
diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp
index 4387813..13f5394 100644
--- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp
+++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginPackageQt.cpp
@@ -151,8 +151,8 @@ bool PluginPackage::load()
m_browserFuncs.getproperty = _NPN_GetProperty;
m_browserFuncs.setproperty = _NPN_SetProperty;
m_browserFuncs.removeproperty = _NPN_RemoveProperty;
- m_browserFuncs.hasproperty = _NPN_HasMethod;
- m_browserFuncs.hasmethod = _NPN_HasProperty;
+ m_browserFuncs.hasproperty = _NPN_HasProperty;
+ m_browserFuncs.hasmethod = _NPN_HasMethod;
m_browserFuncs.setexception = _NPN_SetException;
m_browserFuncs.enumerate = _NPN_Enumerate;
m_browserFuncs.construct = _NPN_Construct;
diff --git a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp
index 43c772f..e856f92 100644
--- a/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/src/3rdparty/webkit/WebCore/plugins/qt/PluginViewQt.cpp
@@ -113,7 +113,9 @@ void PluginView::show()
if (isParentVisible() && platformPluginWidget())
platformPluginWidget()->setVisible(true);
- Widget::show();
+ // do not call parent impl. here as it will set the platformWidget
+ // (same as platformPluginWidget in the Qt port) to visible, even
+ // when parent isn't visible.
}
void PluginView::hide()
@@ -123,7 +125,9 @@ void PluginView::hide()
if (isParentVisible() && platformPluginWidget())
platformPluginWidget()->setVisible(false);
- Widget::hide();
+ // do not call parent impl. here as it will set the platformWidget
+ // (same as platformPluginWidget in the Qt port) to invisible, even
+ // when parent isn't visible.
}
void PluginView::paint(GraphicsContext* context, const IntRect& rect)
diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog
index 2aeb8da..d9f925a 100644
--- a/src/3rdparty/webkit/WebKit/qt/ChangeLog
+++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog
@@ -1,3 +1,17 @@
+2009-05-19 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
+
+ Reviewed by Simon Hausmann.
+
+ Fix a plugin bug in the WebKit code, similar to the one in WebCore.
+
+ The problem is when a non visible QtPluginWidget would show it self
+ in a sibling frame. The problem was due to our clipping. In Qt,
+ if setMask is set with an empty QRegion, no clipping will
+ be performed, so in that case we hide the PluginContainer
+
+ * WebCoreSupport/FrameLoaderClientQt.cpp:
+ (WebCore::):
+
2009-03-27 Erik L. Bunce <elbunce@xendom.com>
Reviewed by Simon Hausmann.
diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
index c421d42..a2b33c0 100644
--- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
+++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
@@ -1058,7 +1058,13 @@ public:
IntRect clipRect(static_cast<FrameView*>(parentScrollView)->windowClipRect());
clipRect.move(-windowRect.x(), -windowRect.y());
clipRect.intersect(platformWidget()->rect());
- platformWidget()->setMask(QRegion(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height()));
+
+ QRegion clipRegion = QRegion(clipRect);
+ platformWidget()->setMask(clipRegion);
+
+ // if setMask is set with an empty QRegion, no clipping will
+ // be performed, so in that case we hide the platformWidget
+ platformWidget()->setVisible(!clipRegion.isEmpty());
}
};
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 2f05f6e..c39588c 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -140,15 +140,6 @@ static void qt_native_close(int fd)
} while (ret == -1 && errno == EINTR);
}
-static void qt_native_sigaction(int signum, const struct sigaction *act,
- struct sigaction *oldact)
-{
- int ret;
- do {
- ret = ::sigaction(signum, act, oldact);
- } while (ret == -1 && errno == EINTR);
-}
-
static void qt_native_dup2(int oldfd, int newfd)
{
int ret;
@@ -255,7 +246,7 @@ QProcessManager::QProcessManager()
memset(&action, 0, sizeof(action));
action.sa_handler = qt_sa_sigchld_handler;
action.sa_flags = SA_NOCLDSTOP;
- qt_native_sigaction(SIGCHLD, &action, &oldAction);
+ ::sigaction(SIGCHLD, &action, &oldAction);
if (oldAction.sa_handler != qt_sa_sigchld_handler)
qt_sa_old_sigchld_handler = oldAction.sa_handler;
}
@@ -282,9 +273,9 @@ QProcessManager::~QProcessManager()
memset(&action, 0, sizeof(action));
action.sa_handler = qt_sa_old_sigchld_handler;
action.sa_flags = SA_NOCLDSTOP;
- qt_native_sigaction(SIGCHLD, &action, &oldAction);
+ ::sigaction(SIGCHLD, &action, &oldAction);
if (oldAction.sa_handler != qt_sa_sigchld_handler) {
- qt_native_sigaction(SIGCHLD, &oldAction, 0);
+ ::sigaction(SIGCHLD, &oldAction, 0);
}
}
@@ -906,7 +897,7 @@ static void qt_ignore_sigpipe()
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
}
}
@@ -1276,7 +1267,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
::setsid();
@@ -1322,7 +1313,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
// '\1' means execv failed
char c = '\1';
@@ -1333,7 +1324,7 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
struct sigaction noaction;
memset(&noaction, 0, sizeof(noaction));
noaction.sa_handler = SIG_IGN;
- qt_native_sigaction(SIGPIPE, &noaction, 0);
+ ::sigaction(SIGPIPE, &noaction, 0);
// '\2' means internal error
char c = '\2';
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index 7e93f74..aac7c31 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -275,13 +275,6 @@ inline qreal QTransform::dy() const
return affine._dy;
}
-#if defined(Q_CC_GNU)
-# define Q_CC_GNU_VERSION (((__GNUC__)<<16)|((__GNUC_MINOR__)<<8)|(__GNUC_PATCHLEVEL__))
-# if Q_CC_GNU_VERSION >= 0x040201
-# pragma GCC diagnostic ignored "-Wfloat-equal"
-# endif
-#endif
-
inline QTransform &QTransform::operator*=(qreal num)
{
if (num == 1.)
@@ -338,13 +331,6 @@ inline QTransform &QTransform::operator-=(qreal num)
return *this;
}
-#if defined(Q_CC_GNU_VERSION)
-# if Q_CC_GNU_VERSION >= 0x040201
-# pragma GCC diagnostic warning "-Wfloat-equal"
-# endif
-# undef Q_CC_GNU_VERSION
-#endif
-
/****** stream functions *******************/
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTransform &);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QTransform &);
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 99d7261..07cec93 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -633,31 +633,14 @@ GtkStyle* QGtk::gtkStyle(const QString &path)
return 0;
}
-#ifdef Q_OS_LINUX
-QT_END_NAMESPACE
-
-int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
-int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
-
-QT_BEGIN_NAMESPACE
-#endif
-
void QGtk::initGtkWidgets()
{
// From gtkmain.c
-
- uid_t ruid, rgid, euid, egid, suid, sgid;
-
-#ifdef Q_OS_LINUX
- if (getresuid (&ruid, &euid, &suid) != 0 || getresgid (&rgid, &egid, &sgid) != 0)
-#endif
- {
- suid = ruid = getuid ();
- sgid = rgid = getgid ();
- euid = geteuid ();
- egid = getegid ();
- }
- if (ruid != euid || ruid != suid || rgid != egid || rgid != sgid) {
+ uid_t ruid = getuid ();
+ uid_t rgid = getgid ();
+ uid_t euid = geteuid ();
+ uid_t egid = getegid ();
+ if (ruid != euid || rgid != egid) {
qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
"therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
"\'kdesudo\' or a similar tool.\n\n"
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 6972803..a46dbd7 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1695,7 +1695,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
pr.setHeight(pmSize.height() + 6);
- tr.adjust(0, pr.height(), 0, -3);
+ tr.adjust(0, pr.height() - 1, 0, -3);
pr.translate(shiftX, shiftY);
if (!hasArrow) {
drawItemPixmap(p, pr, Qt::AlignCenter, pm);
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 6b5bd0f..2e62086 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -553,7 +553,9 @@ QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph)
8, im.bytesPerLine(), colorspace,
cgflags);
CGContextSetFontSize(ctx, fontDef.pixelSize);
- CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold && !(fontDef.styleStrategy & QFont::NoAntialias));
+ CGContextSetShouldAntialias(ctx, fontDef.pointSize > qt_antialiasing_threshold
+ && !(fontDef.styleStrategy & QFont::NoAntialias));
+ CGContextSetShouldSmoothFonts(ctx, false);
CGAffineTransform oldTextMatrix = CGContextGetTextMatrix(ctx);
CGAffineTransform cgMatrix = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index faa06b7..ed6205a 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1099,6 +1099,16 @@ void QTextEngine::shapeTextWithCE(int item) const
}
#endif
+static inline void moveGlyphData(const QGlyphLayout &destination, const QGlyphLayout &source, int num)
+{
+ if (num > 0 && destination.glyphs != source.glyphs) {
+ memmove(destination.glyphs, source.glyphs, num * sizeof(HB_Glyph));
+ memmove(destination.attributes, source.attributes, num * sizeof(HB_GlyphAttributes));
+ memmove(destination.advances_x, source.advances_x, num * sizeof(HB_Fixed));
+ memmove(destination.offsets, source.offsets, num * sizeof(HB_FixedPoint));
+ }
+}
+
/// take the item from layoutData->items and
void QTextEngine::shapeTextWithHarfbuzz(int item) const
{
@@ -1189,7 +1199,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
- int initial_glyph_pos = 0;
+ int remaining_glyphs = entire_shaper_item.num_glyphs;
int glyph_pos = 0;
// for each item shape using harfbuzz and store the results in our layoutData's glyphs array.
for (int k = 0; k < itemBoundaries.size(); k += 2) { // for the +2, see the comment at the definition of itemBoundaries
@@ -1209,7 +1219,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
QFontEngine *actualFontEngine = font;
uint engineIdx = 0;
if (font->type() == QFontEngine::Multi) {
- engineIdx = uint(initialGlyphs.glyphs[itemBoundaries[k + 1]] >> 24);
+ engineIdx = uint(availableGlyphs(&si).glyphs[glyph_pos] >> 24);
actualFontEngine = static_cast<QFontEngineMulti *>(font)->engine(engineIdx);
}
@@ -1219,16 +1229,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
shaper_item.glyphIndicesPresent = true;
+ remaining_glyphs -= shaper_item.initialGlyphCount;
+
do {
- ensureSpace(glyph_pos + shaper_item.num_glyphs);
- initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs);
- shaper_item.num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used - glyph_pos;
+ ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs);
- const QGlyphLayout g = availableGlyphs(&si);
- shaper_item.glyphs = g.glyphs + glyph_pos;
- shaper_item.attributes = g.attributes + glyph_pos;
- shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x + glyph_pos);
- shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets + glyph_pos);
+ const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos);
+ moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
+
+ shaper_item.glyphs = g.glyphs;
+ shaper_item.attributes = g.attributes;
+ shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x);
+ shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets);
if (shaper_item.glyphIndicesPresent) {
for (hb_uint32 i = 0; i < shaper_item.initialGlyphCount; ++i)
@@ -1241,18 +1253,18 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
} while (!qShapeItem(&shaper_item)); // this does the actual shaping via harfbuzz.
QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos, shaper_item.num_glyphs);
+ moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs);
- for (hb_uint32 i = 0; i < shaper_item.item.length; ++i) {
+ for (hb_uint32 i = 0; i < shaper_item.num_glyphs; ++i)
g.glyphs[i] = g.glyphs[i] | (engineIdx << 24);
+
+ for (hb_uint32 i = 0; i < shaper_item.item.length; ++i)
shaper_item.log_clusters[i] += glyph_pos;
- }
if (kerningEnabled && !shaper_item.kerning_applied)
font->doKerning(&g, option.useDesignMetrics() ? QFlag(QTextEngine::DesignMetrics) : QFlag(0));
glyph_pos += shaper_item.num_glyphs;
-
- initial_glyph_pos += shaper_item.initialGlyphCount;
}
// qDebug(" -> item: script=%d num_glyphs=%d", shaper_item.script, shaper_item.num_glyphs);
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 3366f2d..825c333 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -90,6 +90,15 @@ static inline int qt_socket_socket(int domain, int type, int protocol)
#endif
+union qt_sockaddr {
+ sockaddr a;
+ sockaddr_in a4;
+#if !defined(QT_NO_IPV6)
+ sockaddr_in6 a6;
+#endif
+ sockaddr_storage storage;
+};
+
class QNativeSocketEnginePrivate;
class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index cc372a6..2b11e8e 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -114,36 +114,34 @@ static void qt_ignore_sigpipe()
Extracts the port and address from a sockaddr, and stores them in
\a port and \a addr if they are non-null.
*/
-static inline void qt_socket_getPortAndAddress(struct sockaddr *sa, quint16 *port, QHostAddress *addr)
+static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *port, QHostAddress *addr)
{
#if !defined(QT_NO_IPV6)
- if (sa->sa_family == AF_INET6) {
- struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)sa;
+ if (s->a.sa_family == AF_INET6) {
Q_IPV6ADDR tmp;
- memcpy(&tmp, &sa6->sin6_addr.s6_addr, sizeof(tmp));
+ memcpy(&tmp, &s->a6.sin6_addr.s6_addr, sizeof(tmp));
if (addr) {
QHostAddress tmpAddress;
tmpAddress.setAddress(tmp);
*addr = tmpAddress;
#ifndef QT_NO_IPV6IFNAME
char scopeid[IFNAMSIZ];
- if (::if_indextoname(sa6->sin6_scope_id, scopeid) > 0) {
+ if (::if_indextoname(s->a6.sin6_scope_id, scopeid) > 0) {
addr->setScopeId(QLatin1String(scopeid));
} else
#endif
- addr->setScopeId(QString::number(sa6->sin6_scope_id));
+ addr->setScopeId(QString::number(s->a6.sin6_scope_id));
}
if (port)
- *port = ntohs(sa6->sin6_port);
+ *port = ntohs(s->a6.sin6_port);
return;
}
#endif
- struct sockaddr_in *sa4 = (struct sockaddr_in *)sa;
if (port)
- *port = ntohs(sa4->sin_port);
+ *port = ntohs(s->a4.sin_port);
if (addr) {
QHostAddress tmpAddress;
- tmpAddress.setAddress(ntohl(sa4->sin_addr.s_addr));
+ tmpAddress.setAddress(ntohl(s->a4.sin_addr.s_addr));
*addr = tmpAddress;
}
}
@@ -521,26 +519,16 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
{
// Create a sockaddr struct and reset its port number.
-#if !defined(QT_NO_IPV6)
- struct sockaddr_storage storage;
- sockaddr_in6 *storagePtrIPv6 = reinterpret_cast<sockaddr_in6 *>(&storage);
- storagePtrIPv6->sin6_port = 0;
-#else
- struct sockaddr storage;
-#endif
- sockaddr *storagePtr = reinterpret_cast<sockaddr *>(&storage);
- storagePtr->sa_family = 0;
-
- sockaddr_in *storagePtrIPv4 = reinterpret_cast<sockaddr_in *>(&storage);
- storagePtrIPv4->sin_port = 0;
+ qt_sockaddr storage;
QT_SOCKLEN_T storageSize = sizeof(storage);
+ memset(&storage, 0, storageSize);
// Peek 0 bytes into the next message. The size of the message may
// well be 0, so we can't check recvfrom's return value.
ssize_t readBytes;
do {
char c;
- readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, storagePtr, &storageSize);
+ readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
} while (readBytes == -1 && errno == EINTR);
// If there's no error, or if our buffer was too small, there must be a
@@ -583,11 +571,7 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxSize,
QHostAddress *address, quint16 *port)
{
-#if !defined(QT_NO_IPV6)
- struct sockaddr_storage aa;
-#else
- struct sockaddr_in aa;
-#endif
+ qt_sockaddr aa;
memset(&aa, 0, sizeof(aa));
QT_SOCKLEN_T sz;
sz = sizeof(aa);
@@ -596,13 +580,13 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
do {
char c;
recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
- 0, (struct sockaddr *)&aa, &sz);
+ 0, &aa.a, &sz);
} while (recvFromResult == -1 && errno == EINTR);
if (recvFromResult == -1) {
setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
} else if (port || address) {
- qt_socket_getPortAndAddress((struct sockaddr *) &aa, port, address);
+ qt_socket_getPortAndAddress(&aa, port, address);
}
#if defined (QNATIVESOCKETENGINE_DEBUG)
@@ -682,21 +666,16 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
if (socketDescriptor == -1)
return false;
-#if !defined(QT_NO_IPV6)
- struct sockaddr_storage sa;
-#else
- struct sockaddr_in sa;
-#endif
- struct sockaddr *sockAddrPtr = (struct sockaddr *) &sa;
+ qt_sockaddr sa;
QT_SOCKLEN_T sockAddrSize = sizeof(sa);
// Determine local address
memset(&sa, 0, sizeof(sa));
- if (::getsockname(socketDescriptor, sockAddrPtr, &sockAddrSize) == 0) {
- qt_socket_getPortAndAddress(sockAddrPtr, &localPort, &localAddress);
+ if (::getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) {
+ qt_socket_getPortAndAddress(&sa, &localPort, &localAddress);
// Determine protocol family
- switch (sockAddrPtr->sa_family) {
+ switch (sa.a.sa_family) {
case AF_INET:
socketProtocol = QAbstractSocket::IPv4Protocol;
break;
@@ -716,8 +695,8 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
}
// Determine the remote address
- if (!::getpeername(socketDescriptor, sockAddrPtr, &sockAddrSize))
- qt_socket_getPortAndAddress(sockAddrPtr, &peerPort, &peerAddress);
+ if (!::getpeername(socketDescriptor, &sa.a, &sockAddrSize))
+ qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress);
// Determine the socket type (UDP/TCP)
int value = 0;
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 989a37a..a68bc8f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -383,7 +383,7 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
{
Q_D(QDirectFBPaintEngine);
d->dirtyClip = true;
- const QPoint bottom = d->transform.map(QPoint(0, path.controlPointRect().y2));
+ const QPoint bottom = d->transform.map(QPoint(0, int(path.controlPointRect().y2)));
if (bottom.y() >= d->lastLockedHeight)
d->lock();
QRasterPaintEngine::clip(path, op);
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index 51fc306..53645c9 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -927,6 +927,7 @@ bool QMYSQLResult::exec()
nullVector[i] = static_cast<my_bool>(val.isNull());
currBind->is_null = &nullVector[i];
currBind->length = 0;
+ currBind->is_unsigned = 0;
switch (val.type()) {
case QVariant::ByteArray:
@@ -973,7 +974,6 @@ bool QMYSQLResult::exec()
currBind->buffer_type = MYSQL_TYPE_DOUBLE;
currBind->buffer = data;
currBind->buffer_length = sizeof(double);
- currBind->is_unsigned = 0;
break;
case QVariant::LongLong:
case QVariant::ULongLong:
@@ -989,7 +989,6 @@ bool QMYSQLResult::exec()
currBind->buffer_type = MYSQL_TYPE_STRING;
currBind->buffer = const_cast<char *>(ba.constData());
currBind->buffer_length = ba.length();
- currBind->is_unsigned = 0;
break; }
}
}
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp
index d63c482..a7031b1 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/sql/drivers/oci/qsql_oci.cpp
@@ -1789,7 +1789,7 @@ bool QOCIResult::prepare(const QString& query)
bool QOCIResult::exec()
{
int r = 0;
- ub2 stmtType;
+ ub2 stmtType=0;
ub4 iters;
ub4 mode;
QList<QByteArray> tmpStorage;
@@ -1803,6 +1803,16 @@ bool QOCIResult::exec()
OCI_ATTR_STMT_TYPE,
d->err);
+ if (r != OCI_SUCCESS && r != OCI_SUCCESS_WITH_INFO) {
+ qOraWarning("QOCIResult::exec: Unable to get statement type:", d->err);
+ setLastError(qMakeError(QCoreApplication::translate("QOCIResult",
+ "Unable to get statement type"), QSqlError::StatementError, d->err));
+#ifdef QOCI_DEBUG
+ qDebug() << "lastQuery()" << lastQuery();
+#endif
+ return false;
+ }
+
if (stmtType == OCI_STMT_SELECT) {
iters = 0;
mode = OCI_DEFAULT;
diff --git a/tests/auto/_networkselftest/_networkselftest.pro b/tests/auto/_networkselftest/_networkselftest.pro
new file mode 100644
index 0000000..9e2ad0e
--- /dev/null
+++ b/tests/auto/_networkselftest/_networkselftest.pro
@@ -0,0 +1,6 @@
+load(qttest_p4)
+
+SOURCES += tst_networkselftest.cpp
+QT = core network
+DEFINES += SRCDIR=\\\"$$PWD\\\"
+
diff --git a/tests/auto/_networkselftest/tst_networkselftest.cpp b/tests/auto/_networkselftest/tst_networkselftest.cpp
new file mode 100644
index 0000000..dab4433
--- /dev/null
+++ b/tests/auto/_networkselftest/tst_networkselftest.cpp
@@ -0,0 +1,592 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtNetwork/QtNetwork>
+#include "../network-settings.h"
+
+class tst_NetworkSelfTest: public QObject
+{
+ Q_OBJECT
+private slots:
+ void hostTest();
+ void dnsResolution_data();
+ void dnsResolution();
+ void serverReachability();
+ void remotePortsOpen_data();
+ void remotePortsOpen();
+
+ // specific protocol tests
+ void ftpServer();
+ void imapServer();
+ void httpServer();
+ void httpsServer();
+ void httpProxy();
+ void httpProxyBasicAuth();
+ void httpProxyNtlmAuth();
+ void socks5Proxy();
+ void socks5ProxyAuth();
+};
+
+class Chat
+{
+public:
+ enum Type {
+ Reconnect,
+ Send,
+ Expect,
+ SkipBytes,
+ DiscardUntil,
+ DiscardUntilDisconnect,
+ Disconnect,
+ RemoteDisconnect,
+ StartEncryption
+ };
+ Chat(Type t, const QByteArray &d)
+ : data(d), type(t)
+ {
+ }
+ Chat(Type t, int val = 0)
+ : value(val), type(t)
+ {
+ }
+
+ static inline Chat send(const QByteArray &data)
+ { return Chat(Send, data); }
+ static inline Chat expect(const QByteArray &data)
+ { return Chat(Expect, data); }
+ static inline Chat discardUntil(const QByteArray &data)
+ { return Chat(DiscardUntil, data); }
+ static inline Chat skipBytes(int count)
+ { return Chat(SkipBytes, count); }
+
+ QByteArray data;
+ int value;
+ Type type;
+};
+
+static QString prettyByteArray(const QByteArray &array)
+{
+ // any control chars?
+ QString result;
+ result.reserve(array.length() + array.length() / 3);
+ for (int i = 0; i < array.length(); ++i) {
+ char c = array.at(i);
+ switch (c) {
+ case '\n':
+ result += "\\n";
+ continue;
+ case '\r':
+ result += "\\r";
+ continue;
+ case '\t':
+ result += "\\t";
+ continue;
+ case '"':
+ result += "\\\"";
+ continue;
+ default:
+ break;
+ }
+
+ if (c < 0x20 || uchar(c) >= 0x7f) {
+ result += '\\';
+ result += QString::number(uchar(c), 8);
+ } else {
+ result += c;
+ }
+ }
+ return result;
+}
+
+static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 2000)
+{
+ QTime timer;
+ timer.start();
+ forever {
+ if (socket->bytesAvailable() >= minBytesAvailable)
+ return true;
+ if (socket->state() == QAbstractSocket::UnconnectedState
+ || timer.elapsed() >= timeout)
+ return false;
+ if (!socket->waitForReadyRead(timeout - timer.elapsed()))
+ return false;
+ }
+}
+
+static bool doSocketFlush(QTcpSocket *socket, int timeout = 2000)
+{
+#ifndef QT_NO_OPENSSL
+ QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
+#endif
+ QTime timer;
+ timer.start();
+ forever {
+ if (socket->bytesToWrite() == 0
+#ifndef QT_NO_OPENSSL
+ && sslSocket->encryptedBytesToWrite() == 0
+#endif
+ )
+ return true;
+ if (socket->state() == QAbstractSocket::UnconnectedState
+ || timer.elapsed() >= timeout)
+ return false;
+ if (!socket->waitForBytesWritten(timeout - timer.elapsed()))
+ return false;
+ }
+}
+
+static void netChat(int port, const QList<Chat> &chat)
+{
+#ifndef QT_NO_OPENSSL
+ QSslSocket socket;
+#else
+ QTcpSocket socket;
+#endif
+
+ socket.connectToHost(QtNetworkSettings::serverName(), port);
+ qDebug() << 0 << "Connecting to server on port" << port;
+ QVERIFY2(socket.waitForConnected(10000),
+ QString("Failed to connect to server in step 0: %1").arg(socket.errorString()).toLocal8Bit());
+
+ // now start the chat
+ QList<Chat>::ConstIterator it = chat.constBegin();
+ for (int i = 1; it != chat.constEnd(); ++it, ++i) {
+ if (it->type != Chat::Reconnect
+ && socket.state() != QAbstractSocket::ConnectedState
+ && socket.state() != QAbstractSocket::ClosingState)
+ QFAIL(QString("Internal error: socket is in invalid state %1 in step %2")
+ .arg(socket.state()).arg(i).toLocal8Bit());
+
+ switch (it->type) {
+ case Chat::Expect: {
+ qDebug() << i << "Expecting" << prettyByteArray(it->data);
+ if (!doSocketRead(&socket, it->data.length()))
+ QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
+
+ // pop that many bytes off the socket
+ QByteArray received = socket.read(it->data.length());
+
+ // is it what we expected?
+ QVERIFY2(received == it->data,
+ QString("Did not receive expected data in step %1: data received was:\n%2")
+ .arg(i).arg(prettyByteArray(received)).toLocal8Bit());
+
+ break;
+ }
+
+ case Chat::DiscardUntil:
+ qDebug() << i << "Discarding until" << prettyByteArray(it->data);
+ while (true) {
+ // scan the buffer until we have our string
+ if (!doSocketRead(&socket, it->data.length()))
+ QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
+
+ QByteArray buffer;
+ buffer.resize(socket.bytesAvailable());
+ socket.peek(buffer.data(), socket.bytesAvailable());
+
+ int pos = buffer.indexOf(it->data);
+ if (pos == -1) {
+ // data not found, keep trying
+ continue;
+ }
+
+ buffer = socket.read(pos + it->data.length());
+ qDebug() << i << "Discarded" << prettyByteArray(buffer);
+ break;
+ }
+ break;
+
+ case Chat::SkipBytes: {
+ qDebug() << i << "Skipping" << it->value << "bytes";
+ if (!doSocketRead(&socket, it->value))
+ QFAIL(QString("Failed to receive data in step %1: timeout").arg(i).toLocal8Bit());
+
+ // now discard the bytes
+ QByteArray buffer = socket.read(it->value);
+ qDebug() << i << "Skipped" << prettyByteArray(buffer);
+ break;
+ }
+
+ case Chat::Send: {
+ qDebug() << i << "Sending" << prettyByteArray(it->data);
+ socket.write(it->data);
+ if (!doSocketFlush(&socket)) {
+ QVERIFY2(socket.state() == QAbstractSocket::ConnectedState,
+ QString("Socket disconnected while sending data in step %1").arg(i).toLocal8Bit());
+ QFAIL(QString("Failed to send data in step %1: timeout").arg(i).toLocal8Bit());
+ }
+ break;
+ }
+
+ case Chat::Disconnect:
+ qDebug() << i << "Disconnecting from host";
+ socket.disconnectFromHost();
+
+ // is this the last command?
+ if (it + 1 != chat.constEnd())
+ break;
+
+ // fall through:
+ case Chat::RemoteDisconnect:
+ case Chat::DiscardUntilDisconnect:
+ qDebug() << i << "Waiting for remote disconnect";
+ if (socket.state() != QAbstractSocket::UnconnectedState)
+ socket.waitForDisconnected(10000);
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState,
+ QString("Socket did not disconnect as expected in step %1").arg(i).toLocal8Bit());
+
+ // any data left?
+ if (it->type == Chat::DiscardUntilDisconnect) {
+ QByteArray buffer = socket.readAll();
+ qDebug() << i << "Discarded in the process:" << prettyByteArray(buffer);
+ }
+
+ if (socket.bytesAvailable() != 0)
+ QFAIL(QString("Unexpected bytes still on buffer when disconnecting in step %1:\n%2")
+ .arg(i).arg(prettyByteArray(socket.readAll())).toLocal8Bit());
+ break;
+
+ case Chat::Reconnect:
+ qDebug() << i << "Reconnecting to server on port" << port;
+ socket.connectToHost(QtNetworkSettings::serverName(), port);
+ QVERIFY2(socket.waitForConnected(10000),
+ QString("Failed to reconnect to server in step %1: %2").arg(i).arg(socket.errorString()).toLocal8Bit());
+ break;
+
+ case Chat::StartEncryption:
+#ifdef QT_NO_OPENSSL
+ QFAIL("Internal error: SSL required for this test");
+#else
+ qDebug() << i << "Starting client encryption";
+ socket.ignoreSslErrors();
+ socket.startClientEncryption();
+ QVERIFY2(socket.waitForEncrypted(5000),
+ QString("Failed to start client encryption in step %1: %2").arg(i)
+ .arg(socket.errorString()).toLocal8Bit());
+ break;
+#endif
+ }
+ }
+}
+
+void tst_NetworkSelfTest::hostTest()
+{
+ // this is a localhost self-test
+ QHostInfo localhost = QHostInfo::fromName("localhost");
+ QCOMPARE(localhost.error(), QHostInfo::NoError);
+ QVERIFY(!localhost.addresses().isEmpty());
+
+ QTcpServer server;
+ QVERIFY(server.listen());
+
+ QTcpSocket socket;
+ socket.connectToHost("127.0.0.1", server.serverPort());
+ QVERIFY(socket.waitForConnected(10000));
+}
+
+void tst_NetworkSelfTest::dnsResolution_data()
+{
+ QTest::addColumn<QString>("hostName");
+ QTest::newRow("local-name") << QtNetworkSettings::serverLocalName();
+ QTest::newRow("fqdn") << QtNetworkSettings::serverName();
+}
+
+void tst_NetworkSelfTest::dnsResolution()
+{
+ QFETCH(QString, hostName);
+ QHostInfo resolved = QHostInfo::fromName(hostName);
+ QVERIFY2(resolved.error() == QHostInfo::NoError,
+ QString("Failed to resolve hostname %1: %2").arg(hostName, resolved.errorString()).toLocal8Bit());
+}
+
+void tst_NetworkSelfTest::serverReachability()
+{
+ // check that we get a proper error connecting to port 1
+ QTcpSocket socket;
+ socket.connectToHost(QtNetworkSettings::serverName(), 1);
+ socket.waitForConnected(10000);
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+ QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
+ QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
+}
+
+void tst_NetworkSelfTest::remotePortsOpen_data()
+{
+ QTest::addColumn<int>("portNumber");
+ QTest::newRow("ftp") << 21;
+ QTest::newRow("ssh") << 22;
+ QTest::newRow("imap") << 143;
+ QTest::newRow("http") << 80;
+ QTest::newRow("https") << 443;
+ QTest::newRow("http-proxy") << 3128;
+ QTest::newRow("http-proxy-auth-basic") << 3129;
+ QTest::newRow("http-proxy-auth-ntlm") << 3130;
+ QTest::newRow("socks5-proxy") << 1080;
+ QTest::newRow("socks5-proxy-auth") << 1081;
+}
+
+void tst_NetworkSelfTest::remotePortsOpen()
+{
+ QFETCH(int, portNumber);
+ QTcpSocket socket;
+ socket.connectToHost(QtNetworkSettings::serverName(), portNumber);
+
+ if (!socket.waitForConnected(10000)) {
+ if (socket.error() == QAbstractSocket::SocketTimeoutError)
+ QFAIL(QString("Network timeout connecting to the server on port %1").arg(portNumber).toLocal8Bit());
+ else
+ QFAIL(QString("Error connecting to server on port %1: %2").arg(portNumber).arg(socket.errorString()).toLocal8Bit());
+ }
+ QVERIFY(socket.state() == QAbstractSocket::ConnectedState);
+}
+
+static QList<Chat> ftpChat()
+{
+ return QList<Chat>() << Chat::expect("220")
+ << Chat::discardUntil("\r\n")
+ << Chat::send("USER anonymous\r\n")
+ << Chat::expect("331")
+ << Chat::discardUntil("\r\n")
+ << Chat::send("PASS user@hostname\r\n")
+ << Chat::expect("230")
+ << Chat::discardUntil("\r\n")
+ << Chat::send("QUIT\r\n")
+ << Chat::expect("221")
+ << Chat::discardUntil("\r\n")
+ << Chat::RemoteDisconnect;
+}
+
+void tst_NetworkSelfTest::ftpServer()
+{
+ netChat(21, ftpChat());
+}
+
+void tst_NetworkSelfTest::imapServer()
+{
+ netChat(143, QList<Chat>()
+ << Chat::expect("* OK ")
+ << Chat::discardUntil("\r\n")
+ << Chat::send("1 CAPABILITY\r\n")
+ << Chat::expect("* CAPABILITY ")
+ << Chat::discardUntil("1 OK")
+ << Chat::discardUntil("\r\n")
+ << Chat::send("2 LOGOUT\r\n")
+ << Chat::discardUntil("2 OK")
+ << Chat::discardUntil("\r\n")
+ << Chat::RemoteDisconnect);
+}
+
+void tst_NetworkSelfTest::httpServer()
+{
+ netChat(80, QList<Chat>()
+ // HTTP/0.9 chat:
+ << Chat::send("GET /\r\n")
+ << Chat::DiscardUntilDisconnect
+
+ // HTTP/1.0 chat:
+ << Chat::Reconnect
+ << Chat::send("GET / HTTP/1.0\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Connection: close\r\n"
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("200 ")
+ << Chat::DiscardUntilDisconnect
+
+ // HTTP/1.0 POST:
+ << Chat::Reconnect
+ << Chat::send("POST / HTTP/1.0\r\n"
+ "Content-Length: 5\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Connection: close\r\n"
+ "\r\n"
+ "Hello")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("200 ")
+ << Chat::DiscardUntilDisconnect
+ );
+}
+
+void tst_NetworkSelfTest::httpsServer()
+{
+#ifndef QT_NO_OPENSSL
+ netChat(443, QList<Chat>()
+ << Chat::StartEncryption
+ << Chat::send("GET / HTTP/1.0\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Connection: close\r\n"
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("200 ")
+ << Chat::DiscardUntilDisconnect);
+#else
+ QSKIP("SSL not enabled, cannot test");
+#endif
+}
+
+void tst_NetworkSelfTest::httpProxy()
+{
+ netChat(3128, QList<Chat>()
+ // proxy GET
+ << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Proxy-connection: close\r\n"
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("200 ")
+ << Chat::DiscardUntilDisconnect
+
+ // proxy CONNECT
+ << Chat::Reconnect
+ << Chat::send("CONNECT " + QtNetworkSettings::serverName().toLatin1() + ":21 HTTP/1.0\r\n"
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("200 ")
+ << Chat::discardUntil("\r\n\r\n")
+ << ftpChat());
+}
+
+void tst_NetworkSelfTest::httpProxyBasicAuth()
+{
+ netChat(3129, QList<Chat>()
+ // test auth required response
+ << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Proxy-connection: close\r\n"
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("407 ")
+ << Chat::discardUntil("\r\nProxy-Authenticate: Basic realm=\"")
+ << Chat::DiscardUntilDisconnect
+
+ // now try sending our credentials
+ << Chat::Reconnect
+ << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Proxy-connection: close\r\n"
+ "Proxy-Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n"
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("200 ")
+ << Chat::DiscardUntilDisconnect);
+}
+
+void tst_NetworkSelfTest::httpProxyNtlmAuth()
+{
+ netChat(3130, QList<Chat>()
+ // test auth required response
+ << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n"
+ "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n"
+ "Proxy-connection: keep-alive\r\n" // NTLM auth will disconnect
+ "\r\n")
+ << Chat::expect("HTTP/1.")
+ << Chat::discardUntil(" ")
+ << Chat::expect("407 ")
+ << Chat::discardUntil("\r\nProxy-Authenticate: NTLM\r\n")
+ << Chat::DiscardUntilDisconnect
+ );
+}
+
+// SOCKSv5 is a binary protocol
+static const char handshakeNoAuth[] = "\5\1\0";
+static const char handshakeOkNoAuth[] = "\5\0";
+static const char handshakeAuthPassword[] = "\5\1\2\1\12qsockstest\10password";
+static const char handshakeOkPasswdAuth[] = "\5\2\1\0";
+static const char handshakeAuthNotOk[] = "\5\377";
+static const char connect1[] = "\5\1\0\1\177\0\0\1\0\25"; // Connect IPv4 127.0.0.1 port 21
+static const char connect2[] = "\5\1\0\3\11localhost\0\25"; // Connect hostname localhost 21
+static const char connected[] = "\5\0\0";
+
+void tst_NetworkSelfTest::socks5Proxy()
+{
+ netChat(1080, QList<Chat>()
+ // IP address connection
+ << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
+ << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth))
+ << Chat::send(QByteArray(connect1, -1 + sizeof connect1))
+ << Chat::expect(QByteArray(connected, -1 + sizeof connected))
+ << Chat::expect("\1") // IPv4 address following
+ << Chat::skipBytes(6) // the server's local address and port
+ << ftpChat()
+
+ // hostname connection
+ << Chat::Reconnect
+ << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
+ << Chat::expect(QByteArray(handshakeOkNoAuth, -1 + sizeof handshakeOkNoAuth))
+ << Chat::send(QByteArray(connect2, -1 + sizeof connect2))
+ << Chat::expect(QByteArray(connected, -1 + sizeof connected))
+ << Chat::expect("\1") // IPv4 address following
+ << Chat::skipBytes(6) // the server's local address and port
+ << ftpChat()
+ );
+}
+
+void tst_NetworkSelfTest::socks5ProxyAuth()
+{
+ netChat(1081, QList<Chat>()
+ // unauthenticated connect -- will get error
+ << Chat::send(QByteArray(handshakeNoAuth, -1 + sizeof handshakeNoAuth))
+ << Chat::expect(QByteArray(handshakeAuthNotOk, -1 + sizeof handshakeAuthNotOk))
+ << Chat::RemoteDisconnect
+
+ // now try to connect with authentication
+ << Chat::Reconnect
+ << Chat::send(QByteArray(handshakeAuthPassword, -1 + sizeof handshakeAuthPassword))
+ << Chat::expect(QByteArray(handshakeOkPasswdAuth, -1 + sizeof handshakeOkPasswdAuth))
+ << Chat::send(QByteArray(connect1, -1 + sizeof connect1))
+ << Chat::expect(QByteArray(connected, -1 + sizeof connected))
+ << Chat::expect("\1") // IPv4 address following
+ << Chat::skipBytes(6) // the server's local address and port
+ << ftpChat()
+ );
+}
+
+QTEST_MAIN(tst_NetworkSelfTest)
+#include "tst_networkselftest.moc"
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 316a695..38fa380 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -4,7 +4,8 @@ TEMPLATE = subdirs
!wince*:SUBDIRS += \
headers
-SUBDIRS += bic \
+SUBDIRS += _networkselftest \
+ bic \
collections \
compile \
compilerwarnings \