summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-08-10 06:56:35 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-08-10 06:56:35 (GMT)
commitf61ec84fc296c6f70011e30788ee511d6b6a18c6 (patch)
tree54b3b81ac83570e65dc9b44b6756005f6ba1efde /tools
parentcc0a411e5e874aa224c26298a109973cb15ea291 (diff)
parentd13418effc5f00474541ae513a30c9a42c2a1cb3 (diff)
downloadQt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.zip
Qt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.tar.gz
Qt-f61ec84fc296c6f70011e30788ee511d6b6a18c6.tar.bz2
Merge commit 'qt/master-stable'
Conflicts: src/corelib/kernel/qobject.cpp src/corelib/tools/qsharedpointer_impl.h src/gui/widgets/qdatetimeedit.cpp src/gui/widgets/qlinecontrol.cpp src/gui/widgets/qlineedit.cpp tests/auto/qcssparser/qcssparser.pro tests/auto/qicoimageformat/tst_qicoimageformat.cpp tests/auto/qmultiscreen/qmultiscreen.pro tests/auto/qresourceengine/qresourceengine.pro tests/auto/qresourceengine/tst_qresourceengine.cpp tests/auto/qscriptv8testsuite/tst_qscriptv8testsuite.cpp
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/installdialog.cpp2
-rw-r--r--tools/assistant/tools/assistant/installdialog.h4
-rw-r--r--tools/designer/src/components/buddyeditor/buddyeditor.cpp2
-rw-r--r--tools/designer/src/components/formeditor/default_actionprovider.cpp15
-rw-r--r--tools/designer/src/components/formeditor/default_actionprovider.h4
-rw-r--r--tools/designer/src/lib/shared/actionprovider_p.h2
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu.cpp86
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menu_p.h3
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menubar.cpp58
-rw-r--r--tools/designer/src/lib/shared/qdesigner_menubar_p.h4
-rw-r--r--tools/designer/src/lib/shared/qdesigner_toolbar.cpp2
-rw-r--r--tools/linguist/shared/profileevaluator.cpp2
-rw-r--r--tools/linguist/shared/profileevaluator.h15
-rw-r--r--tools/qdoc3/htmlgenerator.cpp58
-rw-r--r--tools/qdoc3/tree.cpp2
-rw-r--r--tools/qtestlib/wince/cetcpsync/cetcpsync.pro22
-rw-r--r--tools/qtestlib/wince/cetcpsync/main.cpp191
-rw-r--r--tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp552
-rw-r--r--tools/qtestlib/wince/cetcpsync/qtcesterconnection.h86
-rw-r--r--tools/qtestlib/wince/cetcpsync/remoteconnection.cpp65
-rw-r--r--tools/qtestlib/wince/cetcpsync/remoteconnection.h81
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro17
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/commands.cpp686
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/commands.h292
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp138
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h83
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/main.cpp63
-rw-r--r--tools/qtestlib/wince/cetcpsyncserver/transfer_global.h159
-rw-r--r--tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp200
-rw-r--r--tools/qtestlib/wince/cetest/cetcpsyncconnection.h82
-rw-r--r--tools/qtestlib/wince/cetest/cetest.pro19
-rw-r--r--tools/qtestlib/wince/cetest/deployment.cpp2
-rw-r--r--tools/qtestlib/wince/cetest/main.cpp11
33 files changed, 2903 insertions, 105 deletions
diff --git a/tools/assistant/tools/assistant/installdialog.cpp b/tools/assistant/tools/assistant/installdialog.cpp
index 5a8dfea..2574f1f 100644
--- a/tools/assistant/tools/assistant/installdialog.cpp
+++ b/tools/assistant/tools/assistant/installdialog.cpp
@@ -56,6 +56,7 @@
#include <QtNetwork/QHttp>
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_HTTP
#define QCH_FILENAME 92943
#define QCH_NAMESPACE 92944
@@ -335,4 +336,5 @@ void InstallDialog::browseDirectories()
m_ui.pathLineEdit->setText(dir);
}
+#endif
QT_END_NAMESPACE
diff --git a/tools/assistant/tools/assistant/installdialog.h b/tools/assistant/tools/assistant/installdialog.h
index 62759ec..9e18a22b9 100644
--- a/tools/assistant/tools/assistant/installdialog.h
+++ b/tools/assistant/tools/assistant/installdialog.h
@@ -47,6 +47,8 @@
#include <QtNetwork/QHttpResponseHeader>
#include "ui_installdialog.h"
+#ifndef QT_NO_HTTP
+
QT_BEGIN_NAMESPACE
class QHttp;
@@ -98,4 +100,6 @@ private:
QT_END_NAMESPACE
+#endif
+
#endif // INSTALLDIALOG_H
diff --git a/tools/designer/src/components/buddyeditor/buddyeditor.cpp b/tools/designer/src/components/buddyeditor/buddyeditor.cpp
index 9984b0d..d5c8670 100644
--- a/tools/designer/src/components/buddyeditor/buddyeditor.cpp
+++ b/tools/designer/src/components/buddyeditor/buddyeditor.cpp
@@ -404,7 +404,7 @@ QWidget *BuddyEditor::findBuddy(QLabel *l, const QWidgetList &existingBuddies) c
const QRect geom = l->geometry();
const int y = geom.center().y();
QWidget *neighbour = 0;
- switch (QApplication::layoutDirection()) {
+ switch (l->layoutDirection()) {
case Qt::LeftToRight: { // Walk right to find next managed neighbour
const int xEnd = parent->size().width();
for (int x = geom.right() + 1; x < xEnd; x += DeltaX)
diff --git a/tools/designer/src/components/formeditor/default_actionprovider.cpp b/tools/designer/src/components/formeditor/default_actionprovider.cpp
index 42d1f81..41333f8 100644
--- a/tools/designer/src/components/formeditor/default_actionprovider.cpp
+++ b/tools/designer/src/components/formeditor/default_actionprovider.cpp
@@ -73,9 +73,8 @@ enum { indicatorSize = 2 };
// Position an indicator horizontally over the rectangle, indicating
// 'Insert before' (left or right according to layout direction)
-static inline QRect horizontalIndicatorRect(const QRect &rect)
+static inline QRect horizontalIndicatorRect(const QRect &rect, Qt::LayoutDirection layoutDirection)
{
- const Qt::LayoutDirection layoutDirection = QApplication::layoutDirection();
// Position right?
QRect rc = QRect(rect.x(), 0, indicatorSize, rect.height() - 1);
if (layoutDirection == Qt::RightToLeft)
@@ -91,13 +90,13 @@ static inline QRect verticalIndicatorRect(const QRect &rect)
// Determine the geometry of the indicator by retrieving
// the action under mouse and positioning the bar within its geometry.
-QRect ActionProviderBase::indicatorGeometry(const QPoint &pos) const
+QRect ActionProviderBase::indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const
{
QAction *action = actionAt(pos);
if (!action)
return QRect();
QRect rc = actionGeometry(action);
- return orientation() == Qt::Horizontal ? horizontalIndicatorRect(rc) : verticalIndicatorRect(rc);
+ return orientation() == Qt::Horizontal ? horizontalIndicatorRect(rc, layoutDirection) : verticalIndicatorRect(rc);
}
// Adjust the indicator while dragging. (-1,1) is called to finish a DND operation
@@ -107,7 +106,7 @@ void ActionProviderBase::adjustIndicator(const QPoint &pos)
m_indicator->hide();
return;
}
- const QRect ig = indicatorGeometry(pos);
+ const QRect ig = indicatorGeometry(pos, m_indicator->layoutDirection());
if (ig.isValid()) {
m_indicator->setGeometry(ig);
QPalette p = m_indicator->palette();
@@ -145,9 +144,9 @@ Qt::Orientation QToolBarActionProvider::orientation() const
return m_widget->orientation();
}
-QRect QToolBarActionProvider::indicatorGeometry(const QPoint &pos) const
+QRect QToolBarActionProvider::indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const
{
- const QRect actionRect = ActionProviderBase::indicatorGeometry(pos);
+ const QRect actionRect = ActionProviderBase::indicatorGeometry(pos, layoutDirection);
if (actionRect.isValid())
return actionRect;
// Toolbar differs in that is has no dummy placeholder to 'insert before'
@@ -155,7 +154,7 @@ QRect QToolBarActionProvider::indicatorGeometry(const QPoint &pos) const
const QRect freeArea = ToolBarEventFilter::freeArea(m_widget);
if (!freeArea.contains(pos))
return QRect();
- return orientation() == Qt::Horizontal ? horizontalIndicatorRect(freeArea) : verticalIndicatorRect(freeArea);
+ return orientation() == Qt::Horizontal ? horizontalIndicatorRect(freeArea, layoutDirection) : verticalIndicatorRect(freeArea);
}
// ------------- QMenuBarActionProvider
diff --git a/tools/designer/src/components/formeditor/default_actionprovider.h b/tools/designer/src/components/formeditor/default_actionprovider.h
index 3660f11..270ea36 100644
--- a/tools/designer/src/components/formeditor/default_actionprovider.h
+++ b/tools/designer/src/components/formeditor/default_actionprovider.h
@@ -66,7 +66,7 @@ public:
virtual Qt::Orientation orientation() const = 0;
protected:
- virtual QRect indicatorGeometry(const QPoint &pos) const;
+ virtual QRect indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const;
private:
QWidget *m_indicator;
@@ -84,7 +84,7 @@ public:
Qt::Orientation orientation() const;
protected:
- virtual QRect indicatorGeometry(const QPoint &pos) const;
+ virtual QRect indicatorGeometry(const QPoint &pos, Qt::LayoutDirection layoutDirection) const;
private:
QToolBar *m_widget;
diff --git a/tools/designer/src/lib/shared/actionprovider_p.h b/tools/designer/src/lib/shared/actionprovider_p.h
index b43dee9..5f9b7a0 100644
--- a/tools/designer/src/lib/shared/actionprovider_p.h
+++ b/tools/designer/src/lib/shared/actionprovider_p.h
@@ -86,7 +86,7 @@ template <class Widget>
// actionGeometry() can be wrong sometimes; it returns a geometry that
// stretches to the end of the toolbar/menu bar. So, check from the beginning
// in the case of a horizontal right-to-left orientation.
- const bool checkTopRight = orientation == Qt::Horizontal && QApplication::layoutDirection() == Qt::RightToLeft;
+ const bool checkTopRight = orientation == Qt::Horizontal && w->layoutDirection() == Qt::RightToLeft;
const QPoint topRight = QPoint(w->rect().width(), 0);
for (int index = 0; index < actionCount; ++index) {
QRect g = w->actionGeometry(actions.at(index));
diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp
index c727d8e..6aba65b 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp
@@ -73,6 +73,19 @@ QT_BEGIN_NAMESPACE
using namespace qdesigner_internal;
+// give the user a little more space to click on the sub menu rectangle
+static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection dir)
+{
+ switch (dir) {
+ case Qt::LeftToRight:
+ subMenuRect->setLeft(subMenuRect->left() - 20);
+ break;
+ case Qt::RightToLeft:
+ subMenuRect->setRight(subMenuRect->right() + 20);
+ break;
+ }
+}
+
QDesignerMenu::QDesignerMenu(QWidget *parent) :
QMenu(parent),
m_currentIndex(0),
@@ -325,8 +338,7 @@ bool QDesignerMenu::handleMouseDoubleClickEvent(QWidget *, QMouseEvent *event)
QRect pm_rect;
if (action->menu() || hasSubMenuPixmap(action)) {
pm_rect = subMenuPixmapRect(action);
- pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more
- // space to click
+ extendClickableArea(&pm_rect, layoutDirection());
}
if (!pm_rect.contains(event->pos()) && m_currentIndex != -1)
@@ -381,7 +393,7 @@ bool QDesignerMenu::handleMousePressEvent(QWidget * /*widget*/, QMouseEvent *eve
QAction *action = safeActionAt(index);
QRect pm_rect = subMenuPixmapRect(action);
- pm_rect.setLeft(pm_rect.left() - 20); // give the user a little more space to click
+ extendClickableArea(&pm_rect, layoutDirection());
const int old_index = m_currentIndex;
m_currentIndex = index;
@@ -540,7 +552,7 @@ QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const
{
static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png"));
const QRect g = actionGeometry(action);
- const int x = g.right() - pm.width() - 2;
+ const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - pm.width() - 2) : 2;
const int y = g.top() + (g.height() - pm.height())/2 + 1;
return QRect(x, y, pm.width(), pm.height());
}
@@ -863,38 +875,52 @@ void QDesignerMenu::closeMenuChain()
m_lastSubMenuIndex = -1;
}
-void QDesignerMenu::moveLeft()
+// Close submenu using the left/right keys according to layoutDirection().
+// Return false to indicate the event must be propagated to the menu bar.
+bool QDesignerMenu::hideSubMenuOnCursorKey()
{
if (parentMenu()) {
hide();
- } else {
- closeMenuChain();
- if (QDesignerMenuBar *mb = parentMenuBar()) {
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- mb->moveLeft();
- else
- mb->moveRight();
- }
+ return true;
}
+ closeMenuChain();
update();
+ if (parentMenuBar())
+ return false;
+ return true;
}
-void QDesignerMenu::moveRight()
+// Open a submenu using the left/right keys according to layoutDirection().
+// Return false to indicate the event must be propagated to the menu bar.
+bool QDesignerMenu::showSubMenuOnCursorKey()
{
- QAction *action = currentAction();
+ const QAction *action = currentAction();
- if (qobject_cast<SpecialMenuAction*>(action) || action->isSeparator()) {
+ if (qobject_cast<const SpecialMenuAction*>(action) || action->isSeparator()) {
closeMenuChain();
- if (QDesignerMenuBar *mb = parentMenuBar()) {
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- mb->moveRight();
- else
- mb->moveLeft();
- }
- } else {
- m_lastSubMenuIndex = -1; // force a refresh
- slotShowSubMenuNow();
+ if (parentMenuBar())
+ return false;
+ return true;
}
+ m_lastSubMenuIndex = -1; // force a refresh
+ slotShowSubMenuNow();
+ return true;
+}
+
+void QDesignerMenu::moveLeft()
+{
+ const bool handled = layoutDirection() == Qt::LeftToRight ?
+ hideSubMenuOnCursorKey() : showSubMenuOnCursorKey();
+ if (!handled)
+ parentMenuBar()->moveLeft();
+}
+
+void QDesignerMenu::moveRight()
+{
+ const bool handled = layoutDirection() == Qt::LeftToRight ?
+ showSubMenuOnCursorKey() : hideSubMenuOnCursorKey();
+ if (!handled)
+ parentMenuBar()->moveRight();
}
void QDesignerMenu::moveUp(bool ctrl)
@@ -1053,7 +1079,15 @@ void QDesignerMenu::slotShowSubMenuNow()
if ((menu->windowFlags() & Qt::Popup) != Qt::Popup)
menu->setWindowFlags(Qt::Popup);
const QRect g = actionGeometry(action);
- menu->move(mapToGlobal(g.topRight()));
+ if (layoutDirection() == Qt::LeftToRight) {
+ menu->move(mapToGlobal(g.topRight()));
+ } else {
+ // The position is not initially correct due to the unknown width,
+ // causing it to overlap a bit the first time it is invoked.
+ const QSize menuSize = menu->size();
+ QPoint point = g.topLeft() - QPoint(menu->width() + 10, 0);
+ menu->move(mapToGlobal(point));
+ }
menu->show();
menu->setFocus();
} else {
diff --git a/tools/designer/src/lib/shared/qdesigner_menu_p.h b/tools/designer/src/lib/shared/qdesigner_menu_p.h
index 55d8bcd..93735e6 100644
--- a/tools/designer/src/lib/shared/qdesigner_menu_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menu_p.h
@@ -181,6 +181,9 @@ protected:
void selectCurrentAction();
private:
+ bool hideSubMenuOnCursorKey();
+ bool showSubMenuOnCursorKey();
+
QPoint m_startPosition;
int m_currentIndex;
QAction *m_addItem;
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar.cpp b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
index b53bb8d..2b19142 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_menubar.cpp
@@ -219,18 +219,12 @@ bool QDesignerMenuBar::handleKeyPressEvent(QWidget *, QKeyEvent *e)
case Qt::Key_Left:
e->accept();
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- moveLeft(e->modifiers() & Qt::ControlModifier);
- else
- moveRight(e->modifiers() & Qt::ControlModifier);
+ moveLeft(e->modifiers() & Qt::ControlModifier);
return true;
case Qt::Key_Right:
e->accept();
- if (QApplication::layoutDirection() == Qt::LeftToRight)
- moveRight(e->modifiers() & Qt::ControlModifier);
- else
- moveLeft(e->modifiers() & Qt::ControlModifier);
+ moveRight(e->modifiers() & Qt::ControlModifier);
return true; // no update
case Qt::Key_Up:
@@ -741,28 +735,48 @@ int QDesignerMenuBar::realActionCount() const
return actions().count() - 1; // 1 fake actions
}
-void QDesignerMenuBar::moveLeft(bool ctrl)
+bool QDesignerMenuBar::dragging() const
{
- if (ctrl)
- (void) swap(m_currentIndex, m_currentIndex - 1);
-
- m_currentIndex = qMax(0, --m_currentIndex);
- // Always re-select, swapping destroys order
- updateCurrentAction(true);
+ return m_dragging;
}
-bool QDesignerMenuBar::dragging() const
+void QDesignerMenuBar::moveLeft(bool ctrl)
{
- return m_dragging;
+ if (layoutDirection() == Qt::LeftToRight) {
+ movePrevious(ctrl);
+ } else {
+ moveNext(ctrl);
+ }
}
void QDesignerMenuBar::moveRight(bool ctrl)
{
- if (ctrl)
- (void) swap(m_currentIndex + 1, m_currentIndex);
+ if (layoutDirection() == Qt::LeftToRight) {
+ moveNext(ctrl);
+ } else {
+ movePrevious(ctrl);
+ }
+}
+
+void QDesignerMenuBar::movePrevious(bool ctrl)
+{
+ const bool swapped = ctrl && swapActions(m_currentIndex, m_currentIndex - 1);
+ const int newIndex = qMax(0, m_currentIndex - 1);
+ // Always re-select, swapping destroys order
+ if (swapped || newIndex != m_currentIndex) {
+ m_currentIndex = newIndex;
+ updateCurrentAction(true);
+ }
+}
- m_currentIndex = qMin(actions().count() - 1, ++m_currentIndex);
- updateCurrentAction(!ctrl);
+void QDesignerMenuBar::moveNext(bool ctrl)
+{
+ const bool swapped = ctrl && swapActions(m_currentIndex + 1, m_currentIndex);
+ const int newIndex = qMin(actions().count() - 1, m_currentIndex + 1);
+ if (swapped || newIndex != m_currentIndex) {
+ m_currentIndex = newIndex;
+ updateCurrentAction(!ctrl);
+ }
}
void QDesignerMenuBar::moveUp()
@@ -869,7 +883,7 @@ QAction *QDesignerMenuBar::safeActionAt(int index) const
return actions().at(index);
}
-bool QDesignerMenuBar::swap(int a, int b)
+bool QDesignerMenuBar::swapActions(int a, int b)
{
const int left = qMin(a, b);
int right = qMax(a, b);
diff --git a/tools/designer/src/lib/shared/qdesigner_menubar_p.h b/tools/designer/src/lib/shared/qdesigner_menubar_p.h
index 97a655b..fb820e1 100644
--- a/tools/designer/src/lib/shared/qdesigner_menubar_p.h
+++ b/tools/designer/src/lib/shared/qdesigner_menubar_p.h
@@ -155,10 +155,12 @@ protected:
QAction *safeActionAt(int index) const;
- bool swap(int a, int b);
+ bool swapActions(int a, int b);
private:
void updateCurrentAction(bool selectAction);
+ void movePrevious(bool ctrl);
+ void moveNext(bool ctrl);
QAction *m_addMenu;
QPointer<QMenu> m_activeMenu;
diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
index 2693452..8c0c61d 100644
--- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
+++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp
@@ -466,7 +466,7 @@ QRect ToolBarEventFilter::freeArea(const QToolBar *tb)
QRect exclusionRectangle = actionList.empty() ? handleArea(tb) : tb->actionGeometry(actionList.back());
switch (tb->orientation()) {
case Qt::Horizontal:
- switch (QApplication::layoutDirection()) {
+ switch (tb->layoutDirection()) {
case Qt::LeftToRight:
rc.setX(exclusionRectangle.right() + 1);
break;
diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp
index 5a9095a..fe22067 100644
--- a/tools/linguist/shared/profileevaluator.cpp
+++ b/tools/linguist/shared/profileevaluator.cpp
@@ -256,10 +256,8 @@ public:
ProFile *m_prevProFile; // See m_prevLineNo
};
-#if (!defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && !defined(__SUNPRO_CC)
Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::State, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(ProFileEvaluator::Private::ProLoop, Q_MOVABLE_TYPE);
-#endif
ProFileEvaluator::Private::Private(ProFileEvaluator *q_)
: q(q_)
diff --git a/tools/linguist/shared/profileevaluator.h b/tools/linguist/shared/profileevaluator.h
index f3498c1..ba525b2 100644
--- a/tools/linguist/shared/profileevaluator.h
+++ b/tools/linguist/shared/profileevaluator.h
@@ -50,10 +50,21 @@
#include <QtCore/QStringList>
#include <QtCore/QStack>
+#if (!defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)) && !defined(__SUNPRO_CC)
+# define HAVE_TEMPLATE_CLASS_FRIENDS
+#endif
+
QT_BEGIN_NAMESPACE
class ProFileEvaluator
{
+#ifdef HAVE_TEMPLATE_CLASS_FRIENDS
+private:
+#else
+public:
+#endif
+ class Private;
+
public:
enum TemplateType {
TT_Unknown = 0,
@@ -93,11 +104,11 @@ public:
virtual void fileMessage(const QString &msg); // error() and message() from .pro file
private:
- class Private;
Private *d;
- // This doesn't help gcc 3.3 and sunpro ...
+#ifdef HAVE_TEMPLATE_CLASS_FRIENDS
template<typename T> friend class QTypeInfo;
+#endif
};
QT_END_NAMESPACE
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 425c50b..26874e1 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -539,16 +539,14 @@ int HtmlGenerator::generateAtom(const Atom *atom,
break;
case Atom::AnnotatedList:
{
- const FakeNode *fake = static_cast<const FakeNode *>(relative);
- if (fake && !fake->groupMembers().isEmpty()) {
- QList<Node*> values = tre->groups().values(atom->string());
- QMap<QString, const Node*> nodeMap;
- for (int i = 0; i < values.size(); ++i) {
- const Node* n = values.at(i);
+ QList<Node*> values = tre->groups().values(atom->string());
+ QMap<QString, const Node*> nodeMap;
+ for (int i = 0; i < values.size(); ++i) {
+ const Node* n = values.at(i);
+ if ((n->status() != Node::Internal) && (n->access() != Node::Private))
nodeMap.insert(n->name(),n);
- }
- generateAnnotatedList(fake, marker, nodeMap);
}
+ generateAnnotatedList(relative, marker, nodeMap);
}
break;
case Atom::GeneratedList:
@@ -2021,8 +2019,8 @@ void HtmlGenerator::generateCompactList(const Node *relative,
assume that NumParagraphs is 37. Each paragraph is a
QMap<QString, const Node *>.
*/
- QMap<QString, const Node *> paragraph[NumParagraphs];
- QString paragraphName[NumParagraphs];
+ QMap<QString, const Node *> paragraph[NumParagraphs+1];
+ QString paragraphName[NumParagraphs+1];
QMap<QString, const Node *>::ConstIterator c = classMap.begin();
while (c != classMap.end()) {
@@ -2055,22 +2053,22 @@ void HtmlGenerator::generateCompactList(const Node *relative,
We now want to compute the paragraph offset. Paragraphs 0 to 6
start at offsets 0, 3, 4, 8, 9, 14, 23.
*/
- int paragraphOffset[NumParagraphs + 1];
+ int paragraphOffset[NumParagraphs + 1]; // 37 + 1
int i, j, k;
paragraphOffset[0] = 0;
- for (j = 0; j < NumParagraphs; j++)
+ for (j = 0; j < NumParagraphs; j++) // j = 0..36
paragraphOffset[j + 1] = paragraphOffset[j] + paragraph[j].count();
- int firstOffset[NumColumns + 1];
- int currentOffset[NumColumns];
- int currentParagraphNo[NumColumns];
- int currentOffsetInParagraph[NumColumns];
+ int firstOffset[NumColumns + 1]; // 4 + 1
+ int currentOffset[NumColumns]; // 4
+ int currentParagraphNo[NumColumns]; // 4
+ int currentOffsetInParagraph[NumColumns]; // 4
int numRows = (classMap.count() + NumColumns - 1) / NumColumns;
int curParagNo = 0;
- for (i = 0; i < NumColumns; i++) {
+ for (i = 0; i < NumColumns; i++) { // i = 0..3
firstOffset[i] = qMin(i * numRows, classMap.size());
currentOffset[i] = firstOffset[i];
@@ -2095,11 +2093,18 @@ void HtmlGenerator::generateCompactList(const Node *relative,
out() << "<td>\n</td>\n";
}
else {
- while (currentOffsetInParagraph[i] == paragraph[currentParagraphNo[i]].count()) {
+ while ((currentParagraphNo[i] < NumParagraphs) &&
+ (currentOffsetInParagraph[i] == paragraph[currentParagraphNo[i]].count())) {
++currentParagraphNo[i];
currentOffsetInParagraph[i] = 0;
}
-
+#if 0
+ if (currentParagraphNo[i] >= NumParagraphs) {
+ qDebug() << "### Internal error ###" << __FILE__ << __LINE__
+ << currentParagraphNo[i] << NumParagraphs;
+ currentParagraphNo[i] = NumParagraphs - 1;
+ }
+#endif
out() << "<td align=\"right\">";
if (currentOffsetInParagraph[i] == 0) {
// start a new paragraph
@@ -2109,7 +2114,8 @@ void HtmlGenerator::generateCompactList(const Node *relative,
}
out() << "</td>\n";
- if (!paragraphName[currentParagraphNo[i]].isEmpty()) {
+ if ((currentParagraphNo[i] < NumParagraphs) &&
+ !paragraphName[currentParagraphNo[i]].isEmpty()) {
QMap<QString, const Node *>::Iterator it;
it = paragraph[currentParagraphNo[i]].begin();
for (j = 0; j < currentOffsetInParagraph[i]; j++)
@@ -3708,12 +3714,6 @@ QString HtmlGenerator::getLink(const Atom *atom,
}
inObsoleteLink = true;
}
-#if 0
- qDebug() << "Link to Obsolete entity"
- << (*node)->name();
- qDebug() << " relative entity"
- << relative->name();
-#endif
}
}
}
@@ -3729,8 +3729,6 @@ QString HtmlGenerator::getLink(const Atom *atom,
else if ((*node)->status() == Node::Internal) {
qDebug() << "Link to Internal entity";
}
- //else
- //qDebug() << "Node Status:" << (*node)->status();
#endif
}
@@ -4014,10 +4012,6 @@ void HtmlGenerator::generateQmlInherits(const QmlClassNode* cn,
generateText(text, cn, marker);
out() << "</p>";
}
-// else
-// qDebug() << "generateQmlInherits(): "
-// << "Inherited element not documented -->"
-// << linkPair.first;
}
}
}
diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp
index d75af70..f832062 100644
--- a/tools/qdoc3/tree.cpp
+++ b/tools/qdoc3/tree.cpp
@@ -575,10 +575,12 @@ void Tree::resolveGroups()
if (fake && fake->subType() == Node::Group) {
fake->addGroupMember(i.value());
}
+#if 0
else {
if (prevGroup != i.key())
i.value()->doc().location().warning(tr("No such group '%1'").arg(i.key()));
}
+#endif
prevGroup = i.key();
}
diff --git a/tools/qtestlib/wince/cetcpsync/cetcpsync.pro b/tools/qtestlib/wince/cetcpsync/cetcpsync.pro
new file mode 100644
index 0000000..d1d7c99
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/cetcpsync.pro
@@ -0,0 +1,22 @@
+TARGET = cetcpsync
+DESTDIR = ../../../../bin
+CONFIG += console
+CONFIG -= app_bundle
+QT += network
+QT -= gui
+TEMPLATE = app
+
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+
+INCLUDEPATH += ../cetcpsyncserver
+
+SOURCES += main.cpp \
+ remoteconnection.cpp \
+ qtcesterconnection.cpp
+
+HEADERS += \
+ remoteconnection.h \
+ qtcesterconnection.h
diff --git a/tools/qtestlib/wince/cetcpsync/main.cpp b/tools/qtestlib/wince/cetcpsync/main.cpp
new file mode 100644
index 0000000..73c7350
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/main.cpp
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <iostream>
+#include "qtcesterconnection.h"
+
+using namespace std;
+
+static void showUsage()
+{
+ cout << "cetcpsync is meant to be used by cetest internally." << endl
+ << "For usage instructions remoteconnection.h could be useful." << endl;
+}
+
+const int debugLevel = 0;
+void debugOutput(const QString& text, int level)
+{
+ if (level <= debugLevel)
+ cout << qPrintable(text) << endl;
+}
+
+class Exception
+{
+public:
+ Exception(const QString& msg = QString())
+ : m_message(msg)
+ {}
+
+ QString message() { return m_message; }
+
+protected:
+ QString m_message;
+};
+
+class TooFewParametersException : public Exception
+{
+public:
+ TooFewParametersException(const QLatin1String& cmd, int expectedParameterCount)
+ {
+ m_message = QLatin1String("Command ") + cmd + QLatin1String(" needs at least ");
+ m_message.append(QString::number(expectedParameterCount));
+ m_message.append(QLatin1String(" parameters."));
+ }
+};
+
+static void fileTimeFromString(FILETIME& ft, const QString& str)
+{
+ int idx = str.indexOf("*");
+ if (idx <= 0)
+ return;
+ ft.dwLowDateTime = str.left(idx).toULong();
+ ft.dwHighDateTime = str.mid(idx+1).toULong();
+}
+
+static QString fileTimeToString(FILETIME& ft)
+{
+ return QString::number(ft.dwLowDateTime) + "*" + QString::number(ft.dwHighDateTime);
+}
+
+static int execCommand(const QLatin1String& cmd, int argc, char* argv[])
+{
+ int retval = 0;
+ bool success = true;
+ QtCesterConnection connection;
+ if (cmd == "copyFileToDevice") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.copyFileToDevice(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "copyDirectoryToDevice") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.copyDirectoryToDevice(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "copyFileFromDevice") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.copyFileFromDevice(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "copyDirectoryFromDevice") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.copyDirectoryFromDevice(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "timeStampForLocalFileTime") {
+ if (argc < 1)
+ throw TooFewParametersException(cmd, 1);
+ FILETIME ft;
+ fileTimeFromString(ft, argv[0]);
+ success = connection.timeStampForLocalFileTime(&ft);
+ if (success)
+ cout << qPrintable(fileTimeToString(ft));
+ } else if (cmd == "fileCreationTime") {
+ if (argc < 1)
+ throw TooFewParametersException(cmd, 1);
+ FILETIME ft;
+ success = connection.fileCreationTime(argv[0], &ft);
+ if (success)
+ cout << qPrintable(fileTimeToString(ft));
+ } else if (cmd == "copyFile") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.copyFile(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "copyDirectory") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.copyDirectory(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "deleteFile") {
+ if (argc < 1)
+ throw TooFewParametersException(cmd, 1);
+ success = connection.deleteFile(argv[0]);
+ } else if (cmd == "deleteDirectory") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.deleteDirectory(argv[0], argv[1] == "true", argv[2] == "true");
+ } else if (cmd == "moveFile") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.moveFile(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "moveDirectory") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ success = connection.moveDirectory(argv[0], argv[1], argv[2] == "true");
+ } else if (cmd == "createDirectory") {
+ if (argc < 2)
+ throw TooFewParametersException(cmd, 2);
+ success = connection.createDirectory(argv[0], argv[1] == "true");
+ } else if (cmd == "execute") {
+ if (argc < 3)
+ throw TooFewParametersException(cmd, 3);
+ int timeout = QString(argv[2]).toInt();
+ success = connection.execute(argv[0], argv[1], timeout, &retval);
+ } else if (cmd == "noop") {
+ // do nothing :)
+ success = true;
+ } else {
+ throw Exception("unknown command");
+ }
+
+ return success ? retval : 1;
+}
+
+int main(int argc, char *argv[])
+{
+ if (argc <= 1) {
+ showUsage();
+ return 0;
+ }
+
+ QLatin1String param(argv[1]);
+ int result = 1;
+ try {
+ result = execCommand(param, argc - 2, argv + 2);
+ } catch (Exception e) {
+ cerr << "Error: " << qPrintable(e.message());
+ }
+ return result;
+}
diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
new file mode 100644
index 0000000..76d3b4b
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.cpp
@@ -0,0 +1,552 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qtcesterconnection.h"
+#include <transfer_global.h>
+#include <QtCore/QDir>
+#include <QtCore/QFile>
+#include <QtCore/QFileInfo>
+#include <QtNetwork/QTcpSocket>
+#include <QtNetwork/QHostAddress>
+
+extern void debugOutput(const QString& text, int level);
+
+#pragma warning(disable:4996)
+
+#define END_ERROR(s, a) \
+ if(a) qDebug() << a; \
+ _freeSocket(s); \
+ return false;
+
+QtCesterConnection::QtCesterConnection()
+ : AbstractRemoteConnection()
+{
+}
+
+QtCesterConnection::~QtCesterConnection()
+{
+}
+
+bool QtCesterConnection::connect(QVariantList&)
+{
+ // We connect with each command, so this is always true
+ // The command itself will fail then
+ connected = true;
+ return true;
+}
+
+void QtCesterConnection::disconnect()
+{
+ connected = false;
+}
+
+bool QtCesterConnection::isConnected() const
+{
+ return connected;
+}
+
+bool QtCesterConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists)
+{
+ debugOutput( qPrintable(QString::fromLatin1("Copy File: %1 -> %2").arg(localSource).arg(deviceDest)),0);
+ QFile localFile(localSource);
+ QFileInfo info(localSource);
+ if (!localFile.exists() || !localFile.open(QIODevice::ReadOnly)) {
+ qDebug() << "Could not open File!";
+ return false;
+ }
+
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_CREATE_FILE)) {
+ END_ERROR(socket, "Could not initialized command");
+ }
+
+ CreateFileOptions option;
+ strcpy(option.fileName, qPrintable(deviceDest));
+#ifdef Q_OS_WIN
+ // Copy FileTime for update verification
+ FILETIME creationTime, accessTime, writeTime;
+ HANDLE localHandle = CreateFile(localSource.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
+ if (localHandle != INVALID_HANDLE_VALUE) {
+ if (GetFileTime(localHandle, &creationTime, &accessTime, &writeTime)) {
+ LocalFileTimeToFileTime(&writeTime, &writeTime);
+ option.fileTime = writeTime;
+ }
+ CloseHandle(localHandle);
+ }
+ DWORD attributes = GetFileAttributes(localSource.utf16());
+ if (attributes != -1 )
+ option.fileAttributes = attributes;
+#endif
+ option.fileSize = info.size();
+ option.overwriteExisting = !failIfExists;
+
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send options...");
+ }
+
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Server did not accept configuration");
+ }
+
+ int bytesWritten = 0;
+ const int bufferSize = 1024;
+ QByteArray data;
+ while (bytesWritten < option.fileSize) {
+ data = localFile.read(bufferSize);
+ bytesWritten += data.size();
+#ifdef Q_OS_WIN
+ wprintf( L"%s -> %s (%d / %d) %d %%\r", localSource.utf16() , deviceDest.utf16(),
+ bytesWritten , option.fileSize, (100*bytesWritten)/option.fileSize );
+#endif
+ if (!_sendData(socket, data.constData(), data.size())) {
+ END_ERROR(socket, "Error during file transfer");
+ }
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Got some strange result");
+ }
+ }
+#ifdef Q_OS_WIN
+ wprintf( L"\n"); // We should jump to next line...
+#endif
+ if (bytesWritten != option.fileSize) {
+ END_ERROR(socket, "Did not send sufficient data");
+ }
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive)
+{
+ QTcpSocket* socket = NULL;
+ QFileInfo info(localSource);
+ if (!info.exists() || !info.isDir()) {
+ END_ERROR(socket, "Input directory invalid");
+ }
+
+ createDirectory(deviceDest, true);
+ QDir dir(localSource);
+ QFileInfoList list = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+ foreach(QFileInfo item, list) {
+ QString targetName = deviceDest + QLatin1String("\\") + item.fileName();
+ if (item.isDir()) {
+ if (recursive) {
+ if (!copyDirectoryToDevice(item.absoluteFilePath() , targetName, recursive))
+ return false;
+ }
+ } else {
+ if (!copyFileToDevice(item.absoluteFilePath(), targetName))
+ return false;
+ }
+ }
+ return true;
+}
+
+bool QtCesterConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists)
+{
+ QFile targetFile(localDest);
+ QTcpSocket* socket = 0;
+ if (targetFile.exists() && failIfExists) {
+ END_ERROR(socket, "Local file not supposed to be overwritten");
+ }
+
+ if (!targetFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ END_ERROR(socket, "Could not open local file for writing");
+ }
+
+ if (!_initCommand(socket, COMMAND_READ_FILE)) {
+ END_ERROR(socket, "Could not establish connection");
+ }
+
+ ReadFileOptions option;
+ strcpy(option.fileName, qPrintable(deviceSource));
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send options");
+ }
+
+ QByteArray data;
+ if (!_receiveData(socket, data)) {
+ END_ERROR(socket, "Did not receive any data");
+ }
+
+ ReadFileReply* reply = (ReadFileReply*) data.data();
+ if (!reply->fileValid) {
+ END_ERROR(socket, "Requested file invalid");
+ }
+
+ int fileSize = reply->fileSize;
+ int currentSize = 0;
+ // ### TODO: make a little bit more error-prone
+ do {
+ _sendData(socket, COMMAND_SUCCESS, strlen(COMMAND_SUCCESS));
+ _receiveData(socket, data);
+ currentSize += data.size();
+ targetFile.write(data);
+ } while(currentSize < fileSize);
+
+ _freeSocket(socket);
+ targetFile.close();
+ return true;
+}
+
+bool QtCesterConnection::copyDirectoryFromDevice(const QString& /*deviceSource*/
+ , const QString& /*localDest*/
+ , bool /*recursive*/)
+{
+ qDebug() << "To be implemented!! Should not be needed for autotest system";
+ exit(-1);
+ return false;
+}
+
+bool QtCesterConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists)
+{
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_COPY_FILE)) {
+ END_ERROR(socket, "Could not establish connection for copy");
+ }
+
+ CopyFileOptions option;
+ strcpy(option.from, qPrintable(srcFile));
+ strcpy(option.to, qPrintable(destFile));
+ option.overwriteExisting = !failIfExists;
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send copy options");
+ }
+
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Copy failed");
+ }
+
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory,
+ bool recursive)
+{
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_COPY_DIRECTORY)) {
+ END_ERROR(socket, "Could not establish connection for dir copy");
+ }
+
+ CopyDirectoryOptions option;
+ strcpy(option.from, qPrintable(srcDirectory));
+ strcpy(option.to, qPrintable(destDirectory));
+ option.recursive = recursive;
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send dir copy options");
+ }
+
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Dir Copy failed");
+ }
+
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::deleteFile(const QString &fileName)
+{
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_DELETE_FILE)) {
+ END_ERROR(socket, "Could not establish connection for file deletion");
+ }
+
+ DeleteFileOptions option;
+ strcpy(option.fileName, qPrintable(fileName));
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send file options");
+ }
+
+ if (!_checkResult(socket)) {
+ //END_ERROR(socket, "File Deletion failed");
+ // This is actually not an error so ignore it.
+ }
+
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists)
+{
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_DELETE_DIRECTORY)) {
+ END_ERROR(socket, "Could not establish connection for dir deletion");
+ }
+
+ DeleteDirectoryOptions option;
+ strcpy(option.dirName, qPrintable(directory));
+ option.recursive = recursive;
+ option.failIfContentExists = failIfContentExists;
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send dir options");
+ }
+
+ if (!_checkResult(socket)) {
+ // we do not write an error as this will fail a lot on recursive.
+ END_ERROR(socket, 0);
+ }
+
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::execute(QString program,
+ QString arguments,
+ int timeout,
+ int *returnValue)
+{
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_EXECUTE)) {
+ END_ERROR(socket, "Could not establish connection for dir deletion");
+ }
+
+ ExecuteOptions options;
+ strcpy(options.appName, qPrintable(program));
+ QStringList argList = arguments.split(QLatin1Char(' '));
+ options.argumentsCount = qMin(argList.size(), MAX_ARGUMENTS);
+ options.waitForFinished = true;
+ options.timeout = timeout;
+ if (!_sendData(socket, (char*) &options, sizeof(options))) {
+ END_ERROR(socket, "Could not send dir options");
+ }
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Did not receive an answer");
+ }
+
+ for (int i=0; i < options.argumentsCount; ++i) {
+ char someData[MAX_NAME_LENGTH];
+ strcpy(someData, qPrintable(argList[i]));
+ if (!_sendData(socket, someData, MAX_NAME_LENGTH)) {
+ END_ERROR(socket, "Could not send argument");
+ }
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Failure in argument send");
+ }
+ }
+
+ // trigger the startup
+ if (!_sendData(socket, COMMAND_SUCCESS, strlen(COMMAND_SUCCESS))) {
+ END_ERROR(socket, "Could not trigger startup");
+ }
+
+ const int waitTime = 60 * 60 * 1000;
+ if (!socket->waitForReadyRead(waitTime)) {
+ END_ERROR(socket, "Process timed out");
+ }
+
+ QByteArray result = socket->readAll();
+ if (result != COMMAND_SUCCESS) {
+ if (returnValue)
+ *returnValue = -1; // just some at least
+ END_ERROR(socket, "Application did not start or returned error");
+ }
+
+ if (returnValue)
+ *returnValue = 0;
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::createDirectory(const QString &path, bool deleteBefore)
+{
+ if (deleteBefore)
+ deleteDirectory(path, true, true);
+
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_CREATE_DIRECTORY)) {
+ END_ERROR(socket, "Could not establish connection for dir creation");
+ }
+
+ CreateDirectoryOptions option;
+ strcpy(option.dirName, qPrintable(path));
+ option.recursively = true;
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send dir options");
+ }
+
+ if (!_checkResult(socket)) {
+ END_ERROR(socket, "Dir creation failed");
+ }
+
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::timeStampForLocalFileTime(FILETIME* fTime) const
+{
+ if (!fTime)
+ return false;
+
+ FILETIME copyTime = *fTime;
+ LocalFileTimeToFileTime(&copyTime, &copyTime);
+
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_TIME_STAMP)) {
+ END_ERROR(socket, "Could not establish time stamp connection");
+ }
+
+ if (!_sendData(socket, (char*) &copyTime, sizeof(copyTime))) {
+ END_ERROR(socket, "Could not send stamp time");
+ }
+
+ QByteArray data;
+ if (!_receiveData(socket, data)) {
+ END_ERROR(socket, "Did not receive time stamp or connection interrupted");
+ }
+
+ copyTime = *((FILETIME*)data.data());
+ if (copyTime.dwLowDateTime == -1 && copyTime.dwHighDateTime == -1) {
+ END_ERROR(socket, "remote Time stamp failed!");
+ }
+
+ *fTime = copyTime;
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const
+{
+ if (!deviceCreationTime)
+ return false;
+
+ QTcpSocket* socket = 0;
+ if (!_initCommand(socket, COMMAND_FILE_TIME)) {
+ END_ERROR(socket, "Could not establish connection for file time access");
+ }
+
+ FileTimeOptions option;
+ strcpy(option.fileName, qPrintable(fileName));
+ if (!_sendData(socket, (char*) &option, sizeof(option))) {
+ END_ERROR(socket, "Could not send file time name");
+ }
+
+ QByteArray data;
+ if (!_receiveData(socket, data)) {
+ END_ERROR(socket, "File Time request failed");
+ }
+
+ FILETIME* resultTime = (FILETIME*) data.data();
+ if (resultTime->dwLowDateTime == -1 && resultTime->dwHighDateTime == -1) {
+ END_ERROR(socket, 0);
+ debugOutput("Could not access file time", 0);
+ }
+
+ *deviceCreationTime = *resultTime;
+ _freeSocket(socket);
+ return true;
+}
+
+bool QtCesterConnection::_createSocket(QTcpSocket*& result) const
+{
+ QTcpSocket* sock = new QTcpSocket();
+ QByteArray ipAddress = qgetenv("DEVICE_IP");
+ if (ipAddress.isEmpty()) {
+ qWarning("Error: You need to have DEVICE_IP set");
+ exit(0);
+ }
+ sock->connectToHost(QHostAddress(QString(ipAddress)), 12145);
+
+ if (!sock->waitForConnected()) {
+ qDebug() << "connection timeout...";
+ result = NULL;
+ return false;
+ }
+ result = sock;
+ return true;
+}
+
+void QtCesterConnection::_freeSocket(QTcpSocket*& sock) const
+{
+ if (!sock)
+ return;
+ if (sock->state() == QAbstractSocket::ConnectedState) {
+ sock->disconnectFromHost();
+ // seems like no need to wait
+ //sock->waitForDisconnected();
+ }
+ delete sock;
+ sock = NULL;
+#ifdef Q_OS_WIN
+ Sleep(100);
+#endif
+}
+
+bool QtCesterConnection::_initCommand(QTcpSocket*& sock, const char* command) const
+{
+ QTcpSocket* socket = NULL;
+ if (!_createSocket(socket)) {
+ END_ERROR(socket, "Could not connect to server");
+ }
+
+ if (!_sendData(socket, command, strlen(command)) ||
+ !_checkResult(socket)) {
+ END_ERROR(socket, "Cound not send command");
+ }
+ sock = socket;
+ return true;
+}
+
+bool QtCesterConnection::_sendData(QTcpSocket*& sock, const char* data, int dataSize) const
+{
+ int amount = sock->write(data, dataSize);
+ if (amount != dataSize) {
+ fprintf(stderr, "*******COULD NOT SEND ENOUGH DATA*************\n");
+ }
+ return sock->waitForBytesWritten();
+}
+
+bool QtCesterConnection::_receiveData(QTcpSocket*& sock, QByteArray& data) const
+{
+ if (!sock->waitForReadyRead()) {
+ qDebug() << "did not receive any data";
+ return false;
+ }
+ data = sock->readAll();
+ return true;
+}
+
+bool QtCesterConnection::_checkResult(QTcpSocket*& sock) const
+{
+ QByteArray response;
+ if (!_receiveData(sock, response) || response != COMMAND_SUCCESS)
+ return false;
+ return true;
+}
+
diff --git a/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h
new file mode 100644
index 0000000..d7b8393
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/qtcesterconnection.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef ACTIVESYNC_REMOTECONNECTION_H
+#define ACTIVESYNC_REMOTECONNECTION_H
+
+#include "remoteconnection.h"
+
+class QTcpSocket;
+
+class QtCesterConnection : public AbstractRemoteConnection
+{
+public:
+ QtCesterConnection();
+ virtual ~QtCesterConnection();
+
+ bool connect(QVariantList &list = QVariantList());
+ void disconnect();
+ bool isConnected() const;
+
+ // These functions are designed for transfer between desktop and device
+ // Caution: deviceDest path has to be device specific (eg. no drive letters for CE)
+ bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false);
+ bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true);
+ bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false);
+ bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true);
+
+ bool timeStampForLocalFileTime(FILETIME*) const;
+ bool fileCreationTime(const QString &fileName, FILETIME*) const;
+
+ // These functions only work on files existing on the device
+ bool copyFile(const QString&, const QString&, bool failIfExists = false);
+ bool copyDirectory(const QString&, const QString&, bool recursive = true);
+ bool deleteFile(const QString&);
+ bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false);
+ bool createDirectory(const QString&, bool deleteBefore=false);
+
+ bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL);
+private:
+ bool _createSocket(QTcpSocket*&) const;
+ void _freeSocket(QTcpSocket*&) const;
+ bool _initCommand(QTcpSocket*&, const char*) const;
+ bool _sendData(QTcpSocket*&, const char* data, int dataSize) const;
+ bool _receiveData(QTcpSocket*&, QByteArray&) const;
+ bool _checkResult(QTcpSocket*&) const;
+ bool connected;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp b/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp
new file mode 100644
index 0000000..b197c5c
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/remoteconnection.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "remoteconnection.h"
+
+AbstractRemoteConnection::AbstractRemoteConnection()
+{
+}
+
+AbstractRemoteConnection::~AbstractRemoteConnection()
+{
+}
+
+// Slow but should be ok...
+bool AbstractRemoteConnection::moveFile(const QString &src, const QString &dest, bool FailIfExists)
+{
+ bool result = copyFile(src, dest, FailIfExists);
+ deleteFile(src);
+ return result;
+}
+
+// Slow but should be ok...
+bool AbstractRemoteConnection::moveDirectory(const QString &src, const QString &dest, bool recursive)
+{
+ bool result = copyDirectory(src, dest, true);
+ deleteDirectory(src, recursive);
+ return result;
+}
diff --git a/tools/qtestlib/wince/cetcpsync/remoteconnection.h b/tools/qtestlib/wince/cetcpsync/remoteconnection.h
new file mode 100644
index 0000000..fae6f7f
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsync/remoteconnection.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef REMOTECONNECTION_H
+#define REMOTECONNECTION_H
+
+#include <QtCore/QString>
+#include <QtCore/QVariant>
+#include <windows.h>
+class AbstractRemoteConnection
+{
+public:
+ AbstractRemoteConnection();
+ virtual ~AbstractRemoteConnection();
+
+ virtual bool connect(QVariantList&) = 0;
+ virtual void disconnect() = 0;
+ virtual bool isConnected() const = 0;
+
+ // These functions are designed for transfer between desktop and device
+ // Caution: deviceDest path has to be device specific (eg. no drive letters for CE)
+ virtual bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false) = 0;
+ virtual bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true) = 0;
+ virtual bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false) = 0;
+ virtual bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true) = 0;
+
+ // For "intelligent deployment" we need to investigate on filetimes on the device
+ virtual bool timeStampForLocalFileTime(FILETIME*) const = 0;
+ virtual bool fileCreationTime(const QString &fileName, FILETIME*) const = 0;
+
+ // These functions only work on files existing on the device
+ virtual bool copyFile(const QString&, const QString&, bool failIfExists = false) = 0;
+ virtual bool copyDirectory(const QString&, const QString&, bool recursive = true) = 0;
+ virtual bool deleteFile(const QString&) = 0;
+ virtual bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false) = 0;
+ bool moveFile(const QString&, const QString&, bool FailIfExists = false);
+ bool moveDirectory(const QString&, const QString&, bool recursive = true);
+
+ virtual bool createDirectory(const QString&, bool deleteBefore=false) = 0;
+
+ virtual bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL) = 0;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro b/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro
new file mode 100644
index 0000000..bd01d2d
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/cetcpsyncserver.pro
@@ -0,0 +1,17 @@
+TEMPLATE = app
+TARGET = cetcpsyncsvr
+DEPENDPATH += .
+QT -= gui
+QT += network
+
+CONFIG += console
+
+HEADERS += \
+ connectionmanager.h \
+ commands.h \
+ transfer_global.h
+
+SOURCES += \
+ connectionmanager.cpp \
+ commands.cpp \
+ main.cpp
diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.cpp b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
new file mode 100644
index 0000000..0c4d3bc
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/commands.cpp
@@ -0,0 +1,686 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "commands.h"
+#include <QtCore/QDebug>
+#include <QtCore/QFileInfo>
+#include <QtCore/QDir>
+#include <QtCore/QProcess>
+
+#ifdef Q_OS_WINCE
+#include <windows.h>
+#endif
+
+/////////////////////////////////////////////////////
+// Abstract Command Implementation //
+/////////////////////////////////////////////////////
+AbstractCommand::AbstractCommand()
+: m_socket(0)
+{
+}
+
+AbstractCommand::~AbstractCommand()
+{
+}
+
+void AbstractCommand::reportSuccess()
+{
+ m_socket->write(COMMAND_SUCCESS, strlen(COMMAND_SUCCESS));
+ m_socket->waitForBytesWritten();
+}
+
+void AbstractCommand::reportError()
+{
+ m_socket->write(COMMAND_ERROR, strlen(COMMAND_ERROR));
+ m_socket->waitForBytesWritten();
+}
+
+void AbstractCommand::dataReceived(QByteArray&)
+{
+ debugOutput(1, "AbstractCommand::dataReceived NOT SUPPOSED TO BE HERE");
+}
+
+void AbstractCommand::commandFinished()
+{
+ debugOutput(1, "AbstractCommand::commandFinished()NOT SUPPOSED TO BE HERE");
+}
+
+void AbstractCommand::setSocket(QTcpSocket* socket)
+{
+ debugOutput(0, "AbstractCommand::setSocket()");
+ Q_ASSERT(socket);
+ m_socket = socket;
+ connect(m_socket, SIGNAL(readyRead()), this, SLOT(_readData()));
+ reportSuccess();
+}
+
+QTcpSocket* AbstractCommand::socket()
+{
+ return m_socket;
+}
+
+void AbstractCommand::_readData()
+{
+ QByteArray arr = m_socket->readAll();
+ dataReceived(arr);
+}
+
+void AbstractCommand::_disconnect()
+{
+}
+
+/////////////////////////////////////////////////////
+// Create File Command Implementation //
+/////////////////////////////////////////////////////
+CreateFileCommand::CreateFileCommand()
+: m_dataCount(0)
+{
+ debugOutput(0, "CreateFileCommand::CreateFileCommand");
+ m_options.fileSize= -1;
+}
+
+CreateFileCommand::~CreateFileCommand()
+{
+ debugOutput(0, "CreateFileCommand::~CreateFileCommand");
+ if (m_file.isOpen()) {
+ fprintf(stderr, "****************FILE IS STILL OPENED AND HAVENT FINISHED WRITING**********************\n");
+ fprintf(stderr, "Current: %d Expected: %d\n", m_dataCount , m_options.fileSize);
+ m_file.close();
+ }
+}
+
+void CreateFileCommand::dataReceived(QByteArray &data)
+{
+ bool successful = true;
+ // If we haven't received the options yet
+ if (m_options.fileSize == -1) {
+ CreateFileOptions* opt = (CreateFileOptions*) data.data();
+ memcpy(&m_options , opt , sizeof(CreateFileOptions));
+
+ if (QFileInfo(QString::fromLatin1(m_options.fileName)).exists()) {
+ if (m_options.overwriteExisting) {
+#ifdef Q_OS_WINCE
+ SetFileAttributes(QFileInfo(m_options.fileName).absoluteFilePath().utf16(), FILE_ATTRIBUTE_NORMAL);
+#endif
+ QFile::remove(m_options.fileName);
+ } else
+ successful = false;
+ }
+ m_file.setFileName(QString::fromLatin1(m_options.fileName));
+ if (!m_file.open(QIODevice::WriteOnly))
+ successful = false;
+ else
+ debugOutput(3, QString::fromLatin1("Creating file: %1").arg(m_options.fileName));
+ } else { // write buffer on disc
+ if (!m_file.isOpen())
+ return;
+ m_file.write(data);
+ m_dataCount += data.size();
+ if (m_dataCount >= m_options.fileSize) {
+ // We do not care about more data than announced
+ m_file.close();
+ }
+ }
+
+ if (successful)
+ reportSuccess();
+ else
+ reportError();
+}
+
+void CreateFileCommand::commandFinished()
+{
+ debugOutput(0, "CreateFileCommand::commandFinished");
+#ifdef Q_OS_WIN
+ // We need to set the file attributes for intelligent time comparisons
+ QString tmpFile = QString::fromLatin1(m_options.fileName);
+ HANDLE handle = CreateFile(tmpFile.utf16(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+ if (handle != INVALID_HANDLE_VALUE) {
+ SetFileTime(handle, &(m_options.fileTime), NULL, NULL);
+ CloseHandle(handle);
+ }
+ SetFileAttributes(tmpFile.utf16(), m_options.fileAttributes);
+#endif
+}
+
+/////////////////////////////////////////////////////
+// Create Directory Command Implementation //
+/////////////////////////////////////////////////////
+CreateDirectoryCommand::CreateDirectoryCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "CreateDirectoryCommand::CreateDirectoryCommand");
+}
+
+CreateDirectoryCommand::~CreateDirectoryCommand()
+{
+ debugOutput(0, "CreateDirectoryCommand::~CreateDirectoryCommand()");
+}
+
+void CreateDirectoryCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "CreateDirectoryCommand::dataReceived()");
+ CreateDirectoryOptions* options = (CreateDirectoryOptions*) data.data();
+ debugOutput(3, QString::fromLatin1("Creating directory: %1").arg(options->dirName));
+ bool success = true;
+ QDir dir;
+ if (options->recursively)
+ success = dir.mkpath(options->dirName);
+ else
+ success = dir.mkdir(options->dirName);
+
+ if (success)
+ reportSuccess();
+ else
+ reportError();
+}
+
+void CreateDirectoryCommand::commandFinished()
+{
+ debugOutput(0, "CreateDirectoryCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// Copy File Command Implementation //
+/////////////////////////////////////////////////////
+CopyFileCommand::CopyFileCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "CopyFileCommand::CopyFileCommand()");
+}
+
+CopyFileCommand::~CopyFileCommand()
+{
+ debugOutput(0, "CopyFileCommand::~CopyFileCommand()");
+}
+
+void CopyFileCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "CopyFileCommand::dataReceived()");
+ CopyFileOptions* options = (CopyFileOptions*) data.data();
+ debugOutput(3, QString::fromLatin1("Copy File: %1 -> %2").arg(options->from).arg(options->to));
+ bool success = true;
+ if (QFileInfo(options->to).exists()) {
+ if (options->overwriteExisting)
+ QFile::remove(options->to);
+ else
+ success = false;
+ }
+ if (success)
+ if (!QFile::copy(options->from , options->to))
+ success = false;
+
+ if (success)
+ reportSuccess();
+ else
+ reportError();
+}
+
+void CopyFileCommand::commandFinished()
+{
+ debugOutput(0, "CopyFileCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// Copy Directory Command Implementation //
+/////////////////////////////////////////////////////
+CopyDirectoryCommand::CopyDirectoryCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "CopyDirectoryCommand::CopyDirectoryCommand()");
+}
+
+CopyDirectoryCommand::~CopyDirectoryCommand()
+{
+ debugOutput(0, "CopyDirectoryCommand::~CopyDirectoryCommand()");
+}
+
+void CopyDirectoryCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "CopyDirectoryCommand::dataReceived()");
+ CopyDirectoryOptions* options = (CopyDirectoryOptions*) data.data();
+ debugOutput(3, QString::fromLatin1("Copy Directory: %1 %2").arg(options->from).arg(options->to));
+ if (copyDir(QLatin1String(options->from) , QLatin1String(options->to) , options->recursive))
+ reportSuccess();
+ else
+ reportError();
+}
+
+void CopyDirectoryCommand::commandFinished()
+{
+ debugOutput(0, "CopyDirectoryCommand::commandFinished()");
+}
+
+bool CopyDirectoryCommand::copyDir(const QString &from, const QString &to, bool recursive)
+{
+ QDir().mkpath(to);
+ QDir sourceDir(from);
+ QDir destDir(to);
+ QStringList entries = sourceDir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+ foreach (QString item , entries) {
+ QString itemFrom = sourceDir.absoluteFilePath(item);
+ QString itemTo = destDir.absoluteFilePath(item);
+ if (QFileInfo(item).isDir()) {
+ if (recursive && !copyDir(itemFrom, itemTo, recursive))
+ return false;
+ } else {
+ if (!QFile::copy(itemFrom, itemTo))
+ return false;
+ }
+ }
+ return true;
+}
+
+/////////////////////////////////////////////////////
+// Delete File Command Implementation //
+/////////////////////////////////////////////////////
+DeleteFileCommand::DeleteFileCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "DeleteFileCommand::DeleteFileCommand()");
+}
+
+DeleteFileCommand::~DeleteFileCommand()
+{
+ debugOutput(0, "DeleteFileCommand::~DeleteFileCommand()");
+}
+
+void DeleteFileCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "DeleteFileCommand::dataReceived()");
+ DeleteFileOptions* options = (DeleteFileOptions*) data.data();
+ debugOutput(3, QString::fromLatin1("Delete File: %1").arg(options->fileName));
+ bool success = true;
+ QFile file(options->fileName);
+ if (file.exists()) {
+#ifdef Q_OS_WINCE
+ SetFileAttributes(QFileInfo(options->fileName).absoluteFilePath().utf16(), FILE_ATTRIBUTE_NORMAL);
+#endif
+ success = file.remove();
+ } else
+ success = false;
+
+ if (success)
+ reportSuccess();
+ else
+ reportError();
+}
+
+void DeleteFileCommand::commandFinished()
+{
+ debugOutput(0, "DeleteFileCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// Delete Directory Command Implementation //
+/////////////////////////////////////////////////////
+DeleteDirectoryCommand::DeleteDirectoryCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "DeleteDirectoryCommand::DeleteDirectoryCommand()");
+}
+
+DeleteDirectoryCommand::~DeleteDirectoryCommand()
+{
+ debugOutput(0, "DeleteDirectoryCommand::~DeleteDirectoryCommand()");
+}
+
+void DeleteDirectoryCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "DeleteDirectoryCommand::dataReceived()");
+ DeleteDirectoryOptions* options = (DeleteDirectoryOptions*) data.data();
+ debugOutput(3, QString::fromLatin1("Delete directory: %1").arg(options->dirName));
+ if (deleteDirectory(QLatin1String(options->dirName), options->recursive, options->failIfContentExists))
+ reportSuccess();
+ else
+ reportError();
+}
+
+void DeleteDirectoryCommand::commandFinished()
+{
+ debugOutput(0, "DeleteDirectoryCommand::commandFinished()");
+}
+
+bool DeleteDirectoryCommand::deleteDirectory(const QString &dirName, bool recursive, bool failIfContentExists)
+{
+ QDir dir(dirName);
+ if (!dir.exists())
+ return false;
+
+ QStringList itemList = dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
+ if (itemList.size() > 0 && failIfContentExists)
+ return false;
+
+ foreach (QString item, itemList) {
+ QString itemName = dir.absoluteFilePath(item);
+ if (QFileInfo(itemName).isDir()) {
+ if (recursive && !deleteDirectory(itemName, recursive, failIfContentExists))
+ return false;
+ } else {
+ if (!dir.remove(item))
+ return false;
+ }
+ }
+ QString lastName = dir.dirName();
+ dir.cdUp();
+ dir.rmpath(lastName);
+ return true;
+}
+
+/////////////////////////////////////////////////////
+// Execute Command Implementation //
+/////////////////////////////////////////////////////
+ExecuteCommand::ExecuteCommand()
+ : AbstractCommand()
+ , m_argumentCount(0)
+ , m_timeout(-1)
+{
+ debugOutput(0, "ExecuteCommand::ExecuteCommand()");
+}
+
+ExecuteCommand::~ExecuteCommand()
+{
+ debugOutput(0, "ExecuteCommand::~ExecuteCommand()");
+}
+
+void ExecuteCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "ExecuteCommand::dataReceived()");
+
+ if (m_argumentCount == 0) {
+ ExecuteOptions* options = (ExecuteOptions*) data.data();
+ if (!QFileInfo(options->appName).exists()) {
+ debugOutput(1, "Error execute: application does not exist");
+ reportError();
+ return;
+ }
+
+ m_program = QLatin1String(options->appName);
+ m_argumentCount = options->argumentsCount;
+ m_waitFinished = options->waitForFinished;
+ m_timeout = options->timeout;
+ if (m_argumentCount == 0)
+ m_argumentCount = -1; // to trigger startup on next receive
+ reportSuccess();
+ } else if (m_arguments.size() < m_argumentCount) {
+ m_arguments += data;
+ reportSuccess();
+ } else { // do the execution
+ if (data == COMMAND_SUCCESS)
+ _doExecute();
+ }
+}
+
+void ExecuteCommand::_doExecute()
+{
+ debugOutput(0, "ExecuteCommand::_doExecute()");
+ debugOutput(3, QString::fromLatin1("Execute: %1 %2").arg(m_program).arg(m_arguments.join(" ")));
+ if (m_waitFinished) {
+ QProcess process;
+ process.start(m_program, m_arguments);
+ if (process.waitForFinished(m_timeout) == false || process.exitCode() < 0)
+ reportError();
+ else
+ reportSuccess();
+ } else {
+ if (QProcess::startDetached(m_program, m_arguments))
+ reportSuccess();
+ else
+ reportError();
+ }
+}
+void ExecuteCommand::commandFinished()
+{
+ debugOutput(0,"ExecuteCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// Read File Implementation //
+/////////////////////////////////////////////////////
+ReadFileCommand::ReadFileCommand()
+ : AbstractCommand()
+ , m_currentPos(0)
+{
+ debugOutput(0, "ReadFileCommand::ReadFileCommand()");
+ m_fileName.clear();
+}
+
+ReadFileCommand::~ReadFileCommand()
+{
+ debugOutput(0, "ReadFileCommand::~ReadFileCommand()");
+ if (m_file.isOpen())
+ m_file.close();
+}
+
+void ReadFileCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "ReadFileCommand::dataReceived()");
+ if (m_fileName.isEmpty()) {
+ ReadFileOptions* option = (ReadFileOptions*) data.data();
+ m_fileName = QLatin1String(option->fileName);
+ QFileInfo info(m_fileName);
+ m_file.setFileName(m_fileName);
+ ReadFileReply reply;
+ if (!info.exists() || !info.isFile() || !m_file.open(QIODevice::ReadOnly))
+ reply.fileValid = false;
+ else
+ reply.fileValid = true;
+ reply.fileSize = info.size();
+ m_fileSize = reply.fileSize;
+ socket()->write((char*) &reply, sizeof(reply));
+ debugOutput(3, QString::fromLatin1("Reading file: %1").arg(m_fileName));
+ } else {
+ QTcpSocket* sock = socket(); // design failure???
+ if (data != COMMAND_SUCCESS || m_currentPos >= m_fileSize) {
+ sock->disconnectFromHost();
+ return;
+ }
+ const int bufferSize = 1024;
+ QByteArray buffer = m_file.read(bufferSize);
+ m_currentPos += buffer.size();
+ sock->write(buffer);
+ sock->waitForBytesWritten();
+ }
+}
+
+void ReadFileCommand::commandFinished()
+{
+ debugOutput(0, "ReadFileCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// Read Directory Implementation //
+/////////////////////////////////////////////////////
+ReadDirectoryCommand::ReadDirectoryCommand()
+ : AbstractCommand()
+ , m_iterator(0)
+{
+ debugOutput(0, "ReadDirectoryCommand::ReadDirectoryCommand");
+ m_dirName.clear();
+}
+
+ReadDirectoryCommand::~ReadDirectoryCommand()
+{
+ debugOutput(0, "ReadDirectoryCommand::~ReadDirectoryCommand()");
+ delete m_iterator;
+}
+
+void ReadDirectoryCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "ReadDirectoryCommand::dataReceived()");
+ QTcpSocket* sock = socket();
+ if (m_dirName.isEmpty()) {
+ ReadDirectoryOptions* option = (ReadDirectoryOptions*) data.data();
+ QFileInfo info(QLatin1String(option->dirName));
+ debugOutput(3, QString::fromLatin1("Reading Directory entries: %1").arg(option->dirName));
+ ReadDirectoryReply reply;
+ if (!info.exists() || !info.isDir()) {
+ reply.itemCount = -1;
+ reply.entryValid = false;
+ } else {
+ m_dirName = QLatin1String(option->dirName);
+ m_dir.setPath(m_dirName);
+ m_iterator = new QDirIterator(m_dir);
+ reply.itemCount = m_dir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot).size();
+ reply.entryValid = true;
+ }
+ sock->write((char*) &reply, sizeof(reply));
+ sock->waitForBytesWritten();
+ } else {
+ if (data != COMMAND_SUCCESS) {
+ qDebug() << "Something went wrong in the meantime";
+ return;
+ }
+ ReadDirectoryItem reply;
+ if (m_iterator->hasNext()) {
+ m_iterator->next();
+ QFileInfo info = m_iterator->fileInfo();
+ strcpy(reply.name, qPrintable(info.absoluteFilePath()));
+ reply.isDirectory = info.isDir();
+ if (!reply.isDirectory)
+ reply.size = info.size();
+ }
+ reply.hasMore = m_iterator->hasNext();
+ sock->write((char*) &reply, sizeof(reply));
+ sock->waitForBytesWritten();
+ }
+}
+
+void ReadDirectoryCommand::commandFinished()
+{
+ debugOutput(0, "ReadDirectoryCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// File Time Implementation //
+/////////////////////////////////////////////////////
+FileTimeCommand::FileTimeCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "FileTimeCommand::FileTimeCommand()");
+}
+
+FileTimeCommand::~FileTimeCommand()
+{
+ debugOutput(0, "FileTimeCommand::~FileTimeCommand()");
+}
+
+void FileTimeCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "FileTimeCommand::dataReceived()");
+ FileTimeOptions* option = (FileTimeOptions*) data.data();
+
+ FILETIME resultTime;
+ resultTime.dwLowDateTime = -1;
+ resultTime.dwHighDateTime = -1;
+
+#ifdef Q_OS_WIN
+ QString fileName = QLatin1String(option->fileName);
+ HANDLE deviceHandle = CreateFile(fileName.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
+ debugOutput(3, QString::fromLatin1("Asking FileTime: %1").arg(fileName));
+ if (deviceHandle != INVALID_HANDLE_VALUE) {
+ FILETIME deviceCreationTime;
+ if (GetFileTime(deviceHandle, &deviceCreationTime, NULL, NULL)) {
+ resultTime = deviceCreationTime;
+ }
+ CloseHandle(deviceHandle);
+ }
+#endif
+ QTcpSocket* sock = socket();
+ sock->write((char*) &resultTime, sizeof(resultTime));
+ sock->waitForBytesWritten();
+}
+
+void FileTimeCommand::commandFinished()
+{
+ debugOutput(0, "FileTimeCommand::commandFinished()");
+}
+
+/////////////////////////////////////////////////////
+// Time Stamp Implementation //
+/////////////////////////////////////////////////////
+TimeStampCommand::TimeStampCommand()
+ : AbstractCommand()
+{
+ debugOutput(0, "TimeStampCommand::TimeStampCommand()");
+}
+
+TimeStampCommand::~TimeStampCommand()
+{
+ debugOutput(0, "TimeStampCommand::~TimeStampCommand()");
+}
+
+void TimeStampCommand::dataReceived(QByteArray &data)
+{
+ debugOutput(0, "TimeStampCommand::dataReceived()");
+ FILETIME resultTime;
+ resultTime.dwLowDateTime = -1;
+ resultTime.dwHighDateTime = -1;
+
+#ifdef Q_OS_WIN
+ FILETIME stampTime = *((FILETIME*)data.data());
+
+ QString tmpFile = QString::fromLatin1("\\qt_tmp_ftime_convert");
+ HANDLE remoteHandle = CreateFile(tmpFile.utf16(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+ if (remoteHandle != INVALID_HANDLE_VALUE) {
+ if (!SetFileTime(remoteHandle, &stampTime, NULL, NULL)) {
+ CloseHandle(remoteHandle);
+ } else {
+ CloseHandle(remoteHandle);
+ remoteHandle = CreateFile(tmpFile.utf16(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+ if (remoteHandle != INVALID_HANDLE_VALUE) {
+ if (GetFileTime(remoteHandle, &stampTime, NULL, NULL))
+ resultTime = stampTime;
+ CloseHandle(remoteHandle);
+ DeleteFile(tmpFile.utf16());
+ }
+ }
+ }
+ debugOutput(3, QString::fromLatin1("Asking TimeStamp"));
+#endif
+ QTcpSocket* sock = socket();
+ sock->write((char*) &resultTime, sizeof(resultTime));
+ sock->waitForBytesWritten();
+}
+
+void TimeStampCommand::commandFinished()
+{
+ debugOutput(0, "TimeStampCommand::commandFinished()");
+}
diff --git a/tools/qtestlib/wince/cetcpsyncserver/commands.h b/tools/qtestlib/wince/cetcpsyncserver/commands.h
new file mode 100644
index 0000000..356c1aa
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/commands.h
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef COMMANDS_INCL
+#define COMMANDS_INCL
+
+#include "transfer_global.h"
+
+#include <QtNetwork/QTcpSocket>
+#include <QtCore/QString>
+#include <QtCore/QFile>
+#include <QtCore/QDir>
+#include <QtCore/QDirIterator>
+#include <windows.h>
+
+// debug output
+#define DEBUG_LEVEL 2
+inline void debugOutput(int level, const char* text)
+{
+ if (level >= DEBUG_LEVEL)
+ qDebug() << text;
+}
+
+inline void debugOutput(int level, const QString &text)
+{
+ if (level >= DEBUG_LEVEL)
+ qDebug() << text;
+}
+// Basic abtract command class
+class AbstractCommand : public QObject
+{
+ Q_OBJECT
+public:
+ AbstractCommand();
+ virtual ~AbstractCommand();
+
+ void setSocket(QTcpSocket*);
+ QTcpSocket* socket();
+
+ void reportSuccess();
+ void reportError();
+
+public slots:
+ virtual void dataReceived(QByteArray&);
+ virtual void commandFinished();
+
+private slots:
+ void _readData();
+ void _disconnect();
+
+private:
+ QTcpSocket* m_socket;
+};
+
+// File Creation class
+class CreateFileCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ CreateFileCommand();
+ ~CreateFileCommand();
+
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+
+private:
+ CreateFileOptions m_options;
+ QFile m_file;
+ int m_dataCount;
+};
+
+inline AbstractCommand* instCreateFile() { return new CreateFileCommand(); }
+
+// Directory Creation class
+class CreateDirectoryCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ CreateDirectoryCommand();
+ ~CreateDirectoryCommand();
+
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+};
+inline AbstractCommand* instCreateDirectory() { return new CreateDirectoryCommand(); }
+
+// File copy class
+class CopyFileCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ CopyFileCommand();
+ ~CopyFileCommand();
+
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+};
+inline AbstractCommand* instCopyFile() { return new CopyFileCommand(); }
+
+// Copy directory class
+class CopyDirectoryCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ CopyDirectoryCommand();
+ ~CopyDirectoryCommand();
+
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+private:
+ bool copyDir(const QString &from, const QString &to, bool recursive);
+};
+inline AbstractCommand* instCopyDirectory() { return new CopyDirectoryCommand(); }
+
+// Delete File class
+class DeleteFileCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ DeleteFileCommand();
+ ~DeleteFileCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+};
+inline AbstractCommand* instDeleteFile() { return new DeleteFileCommand(); }
+
+// Delete Directory class
+class DeleteDirectoryCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ DeleteDirectoryCommand();
+ ~DeleteDirectoryCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+private:
+ bool deleteDirectory(const QString &dirName, bool recursive, bool failIfContentExists);
+};
+inline AbstractCommand* instDeleteDirectory() { return new DeleteDirectoryCommand(); }
+
+// Execute application class
+class ExecuteCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ ExecuteCommand();
+ ~ExecuteCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+private:
+ void _doExecute();
+ QString m_program;
+ QStringList m_arguments;
+ int m_argumentCount;
+ bool m_waitFinished;
+ int m_timeout;
+};
+inline AbstractCommand* instExecution() { return new ExecuteCommand(); }
+
+// Read File class
+class ReadFileCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ ReadFileCommand();
+ ~ReadFileCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+private:
+ QString m_fileName;
+ QFile m_file;
+ qint64 m_currentPos;
+ qint64 m_fileSize;
+};
+inline AbstractCommand* instReadFile() { return new ReadFileCommand(); }
+
+// Read Directory class
+class ReadDirectoryCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ ReadDirectoryCommand();
+ ~ReadDirectoryCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+private:
+ QString m_dirName;
+ QDir m_dir;
+ QDirIterator* m_iterator;
+};
+inline AbstractCommand* instReadDirectory() { return new ReadDirectoryCommand(); }
+
+// Read File Time class
+class FileTimeCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ FileTimeCommand();
+ ~FileTimeCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+};
+inline AbstractCommand* instFileTime() { return new FileTimeCommand(); }
+
+// Time stamp class
+class TimeStampCommand : public AbstractCommand
+{
+ Q_OBJECT
+public:
+ TimeStampCommand();
+ ~TimeStampCommand();
+public slots:
+ void dataReceived(QByteArray&);
+ void commandFinished();
+};
+inline AbstractCommand* instTimeStamp() { return new TimeStampCommand(); }
+
+// Access part
+typedef AbstractCommand* (*instantiator)();
+
+struct CommandInfo
+{
+ CommandInfo(const QString &name, instantiator func) : commandName(name) , commandFunc(func) { }
+ QString commandName;
+ instantiator commandFunc;
+};
+
+inline QList<CommandInfo> availableCommands()
+{
+ QList<CommandInfo> list;
+ list.append(CommandInfo(QLatin1String(COMMAND_CREATE_FILE), instCreateFile));
+ list.append(CommandInfo(QLatin1String(COMMAND_CREATE_DIRECTORY), instCreateDirectory));
+ list.append(CommandInfo(QLatin1String(COMMAND_COPY_FILE), instCopyFile));
+ list.append(CommandInfo(QLatin1String(COMMAND_COPY_DIRECTORY), instCopyDirectory));
+ list.append(CommandInfo(QLatin1String(COMMAND_DELETE_FILE), instDeleteFile));
+ list.append(CommandInfo(QLatin1String(COMMAND_DELETE_DIRECTORY), instDeleteDirectory));
+ list.append(CommandInfo(QLatin1String(COMMAND_EXECUTE), instExecution));
+ list.append(CommandInfo(QLatin1String(COMMAND_READ_FILE), instReadFile));
+ list.append(CommandInfo(QLatin1String(COMMAND_READ_DIRECTORY), instReadDirectory));
+ list.append(CommandInfo(QLatin1String(COMMAND_FILE_TIME), instFileTime));
+ list.append(CommandInfo(QLatin1String(COMMAND_TIME_STAMP), instTimeStamp));
+ return list;
+}
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp
new file mode 100644
index 0000000..901cd12
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "connectionmanager.h"
+#include "commands.h"
+#include <QtCore/QDebug>
+
+ConnectionManager::ConnectionManager()
+ : QObject()
+ , m_server(0)
+{
+ debugOutput(0, "ConnectionManager::ConnectionManager()");
+}
+
+ConnectionManager::~ConnectionManager()
+{
+ debugOutput(0, "ConnectionManager::~ConnectionManager()");
+ cleanUp();
+}
+
+bool ConnectionManager::init()
+{
+ debugOutput(0, "ConnectionManager::init()");
+ debugOutput(3, "Initializing server...");
+ cleanUp();
+ m_server = new QTcpServer(this);
+ connect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
+ bool result = m_server->listen(QHostAddress::Any, SERVER_PORT);
+ if (!result)
+ debugOutput(3, QString::fromLatin1(" Error: Server start failed:") + m_server->errorString());
+ debugOutput(3, " Waiting for action");
+ return result;
+}
+
+void ConnectionManager::cleanUp()
+{
+ debugOutput(0, "ConnectionManager::cleanUp()");
+
+ if (m_server) {
+ debugOutput(1, "Removing server instance...");
+ disconnect(m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
+ delete m_server;
+ m_server = 0;
+ }
+}
+
+void ConnectionManager::newConnection()
+{
+ debugOutput(0, "ConnectionManager::newConnection()");
+
+ QTcpSocket* connection = m_server->nextPendingConnection();
+ if (!connection) {
+ debugOutput(3, "Received connection has empty socket");
+ return;
+ }
+ debugOutput(0, QString::fromLatin1(" received a connection: %1").arg((int) connection));
+ new Connection(connection);
+}
+
+Connection::Connection(QTcpSocket *socket)
+ : QObject()
+ , m_connection(socket)
+ , m_command(0)
+{
+ connect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand()));
+ connect(m_connection, SIGNAL(disconnected()), this, SLOT(closedConnection()));
+}
+
+Connection::~Connection()
+{
+ if (m_command) {
+ m_command->commandFinished();
+ delete m_command;
+ m_command = 0;
+ }
+ delete m_connection;
+}
+
+void Connection::receiveCommand()
+{
+ QByteArray arr = m_connection->readAll();
+ debugOutput(1, QString::fromLatin1("Command received: ") + (arr));
+ QList<CommandInfo> commands = availableCommands();
+ for(QList<CommandInfo>::iterator it = commands.begin(); it != commands.end(); ++it) {
+ if (it->commandName == QString::fromLatin1(arr)) {
+ debugOutput(1, "Found command in list");
+ disconnect(m_connection, SIGNAL(readyRead()), this, SLOT(receiveCommand()));
+ AbstractCommand* command = (*it).commandFunc();
+ command->setSocket(m_connection);
+ m_command = command;
+ return;
+ }
+ }
+ debugOutput(2, QString::fromLatin1("Unknown command received: ") + (arr));
+}
+
+void Connection::closedConnection()
+{
+ debugOutput(0, "connection being closed...");
+ this->deleteLater();
+}
diff --git a/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h
new file mode 100644
index 0000000..21183ac
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/connectionmanager.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef CONNECTION_MANAGER_INCL
+#define CONNECTION_MANAGER_INCL
+
+#include "transfer_global.h"
+#include "commands.h"
+
+#include <QtNetwork/QTcpServer>
+#include <QtNetwork/QTcpSocket>
+
+class Connection : public QObject
+{
+ Q_OBJECT
+public:
+ Connection(QTcpSocket* socket);
+ ~Connection();
+
+public slots:
+ void receiveCommand();
+ void closedConnection();
+
+private:
+ QTcpSocket* m_connection;
+ AbstractCommand* m_command;
+};
+
+class ConnectionManager : public QObject
+{
+ Q_OBJECT
+public:
+ ConnectionManager();
+ ~ConnectionManager();
+
+ bool init();
+
+public slots:
+ void cleanUp();
+ void newConnection();
+
+private:
+ QTcpServer* m_server;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetcpsyncserver/main.cpp b/tools/qtestlib/wince/cetcpsyncserver/main.cpp
new file mode 100644
index 0000000..19d38ea
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "connectionmanager.h"
+
+#include <QtCore>
+#include <QtNetwork>
+
+void messageOutput(QtMsgType type, const char *msg)
+{
+ switch(type) {
+ case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg); break;
+ case QtWarningMsg: fprintf(stderr, "Warning: %s\n", msg); break;
+ default: fprintf(stderr, "Some Msg: %s\n", msg); break;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ qInstallMsgHandler(messageOutput);
+
+ QCoreApplication app(argc, argv);
+ ConnectionManager manager;
+ manager.init();
+ return app.exec();
+}
diff --git a/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h b/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h
new file mode 100644
index 0000000..5b6ff23
--- /dev/null
+++ b/tools/qtestlib/wince/cetcpsyncserver/transfer_global.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef TRANSFER_GLOBAL_H
+#define TRANSFER_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
+#define SERVER_PORT 12145
+
+#define MAX_NAME_LENGTH 512
+#define MAX_ARGUMENTS 10
+
+// Defines for commands sent/received
+#define COMMAND_CREATE_FILE "CREATEFILE"
+#define COMMAND_CREATE_DIRECTORY "CREATEDIR"
+#define COMMAND_COPY_FILE "COPYFILE"
+#define COMMAND_COPY_DIRECTORY "COPYDIR"
+#define COMMAND_DELETE_FILE "DELETEFILE"
+#define COMMAND_DELETE_DIRECTORY "DELETEDIR"
+#define COMMAND_EXECUTE "EXECUTE"
+#define COMMAND_QUIT_SERVER "QUIT"
+#define COMMAND_FILE_TIME "FILETIME"
+#define COMMAND_TIME_STAMP "TIMESTAMP"
+
+// Report back commands
+#define COMMAND_SUCCESS "SUCCESS"
+#define COMMAND_ERROR "ERROR"
+
+// Defines for commands that send data back to requester
+#define COMMAND_READ_FILE "READFILE"
+#define COMMAND_READ_DIRECTORY "READDIR"
+
+#include <QtCore/qglobal.h>
+// Option-Structures for commands
+
+struct CreateFileOptions
+{
+ char fileName[MAX_NAME_LENGTH];
+#ifdef Q_OS_WIN
+ FILETIME fileTime;
+ DWORD fileAttributes;
+#endif
+ int fileSize;
+ bool overwriteExisting;
+};
+
+struct CreateDirectoryOptions
+{
+ char dirName[MAX_NAME_LENGTH];
+ bool recursively; // in case of \foo\bar create \foo if it does not exist
+};
+
+struct CopyFileOptions
+{
+ char from[MAX_NAME_LENGTH];
+ char to[MAX_NAME_LENGTH];
+ bool overwriteExisting;
+};
+
+struct CopyDirectoryOptions
+{
+ char from[MAX_NAME_LENGTH];
+ char to[MAX_NAME_LENGTH];
+ bool recursive;
+};
+
+struct DeleteFileOptions
+{
+ char fileName[MAX_NAME_LENGTH];
+};
+
+struct DeleteDirectoryOptions
+{
+ char dirName[MAX_NAME_LENGTH];
+ bool recursive;
+ bool failIfContentExists;
+};
+
+struct ExecuteOptions
+{
+ char appName[MAX_NAME_LENGTH];
+ int argumentsCount;
+ bool waitForFinished;
+ int timeout;
+};
+
+struct ReadFileOptions
+{
+ char fileName[MAX_NAME_LENGTH];
+};
+
+struct ReadFileReply
+{
+ qint64 fileSize;
+ bool fileValid;
+};
+
+struct ReadDirectoryOptions
+{
+ char dirName[MAX_NAME_LENGTH];
+};
+
+struct ReadDirectoryItem
+{
+ char name[MAX_NAME_LENGTH];
+ qint64 size;
+ bool isDirectory;
+ bool hasMore;
+};
+
+#define FileTimeOptions ReadFileOptions
+
+struct ReadDirectoryReply
+{
+ bool entryValid;
+ int itemCount; // might change during iteration
+};
+#endif
diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
new file mode 100644
index 0000000..621a6ac
--- /dev/null
+++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.cpp
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "CeTcpSyncConnection.h"
+#include <qdir.h>
+#include <qfile.h>
+#include <qfileinfo>
+
+static const QString ceTcpSyncProgram = "cetcpsync";
+extern void debugOutput(const QString& text, int level);
+
+CeTcpSyncConnection::CeTcpSyncConnection()
+ : AbstractRemoteConnection()
+ , connected(false)
+{
+}
+
+CeTcpSyncConnection::~CeTcpSyncConnection()
+{
+ if (isConnected())
+ disconnect();
+}
+
+bool CeTcpSyncConnection::connect(QVariantList&)
+{
+ // We connect with each command, so this is always true
+ // The command itself will fail then
+ const QString cmd = ceTcpSyncProgram + " noop";
+ if (system(qPrintable(cmd)) != 0)
+ return false;
+ connected = true;
+ return true;
+}
+
+void CeTcpSyncConnection::disconnect()
+{
+ connected = false;
+}
+
+bool CeTcpSyncConnection::isConnected() const
+{
+ return connected;
+}
+
+inline QString boolToString(bool b)
+{
+ return b ? "true" : "false";
+}
+
+static bool fileTimeFromString(FILETIME& ft, const QString& str)
+{
+ int idx = str.indexOf("*");
+ if (idx <= 0)
+ return false;
+ bool ok;
+ ft.dwLowDateTime = str.left(idx).toULong(&ok);
+ if (!ok)
+ return false;
+ ft.dwHighDateTime = str.mid(idx+1).toULong(&ok);
+ return ok;
+}
+
+static QString fileTimeToString(FILETIME& ft)
+{
+ return QString::number(ft.dwLowDateTime) + "*" + QString::number(ft.dwHighDateTime);
+}
+
+bool CeTcpSyncConnection::copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists)
+{
+ QString cmd = ceTcpSyncProgram + " copyFileToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(failIfExists);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive)
+{
+ QString cmd = ceTcpSyncProgram + " copyDirectoryToDevice \"" + localSource + "\" \"" + deviceDest + "\" " + boolToString(recursive);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists)
+{
+ QString cmd = ceTcpSyncProgram + " copyFileFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(failIfExists);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive)
+{
+ QString cmd = ceTcpSyncProgram + " copyDirectoryFromDevice \"" + deviceSource + "\" \"" + localDest + "\" " + boolToString(recursive);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyFile(const QString &srcFile, const QString &destFile, bool failIfExists)
+{
+ QString cmd = ceTcpSyncProgram + " copyFile \"" + srcFile + "\" \"" + destFile + "\" " + boolToString(failIfExists);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::copyDirectory(const QString &srcDirectory, const QString &destDirectory,
+ bool recursive)
+{
+ QString cmd = ceTcpSyncProgram + " copyDirectory \"" + srcDirectory + "\" \"" + destDirectory + "\" " + boolToString(recursive);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::deleteFile(const QString &fileName)
+{
+ QString cmd = ceTcpSyncProgram + " deleteFile \"" + fileName + "\"";
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::deleteDirectory(const QString &directory, bool recursive, bool failIfContentExists)
+{
+ QString cmd = ceTcpSyncProgram + " deleteDirectory \"" + directory + "\" " + boolToString(recursive) + " " + boolToString(failIfContentExists);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::execute(QString program, QString arguments, int timeout, int *returnValue)
+{
+ QString cmd = ceTcpSyncProgram + " execute \"" + program + "\" \"" + arguments + "\" " + QString::number(timeout);
+ int exitCode = system(qPrintable(cmd));
+ if (returnValue)
+ *returnValue = exitCode;
+ return true;
+}
+
+bool CeTcpSyncConnection::createDirectory(const QString &path, bool deleteBefore)
+{
+ QString cmd = ceTcpSyncProgram + " createDirectory \"" + path + "\" " + boolToString(deleteBefore);
+ return system(qPrintable(cmd)) == 0;
+}
+
+bool CeTcpSyncConnection::timeStampForLocalFileTime(FILETIME* fTime) const
+{
+ QString cmd = ceTcpSyncProgram + " timeStampForLocalFileTime " + fileTimeToString(*fTime) + " >qt_cetcpsyncdata.txt";
+ if (system(qPrintable(cmd)) != 0)
+ return false;
+
+ QFile file("qt_cetcpsyncdata.txt");
+ if (!file.open(QIODevice::ReadOnly))
+ return false;
+
+ bool result = fileTimeFromString(*fTime, file.readLine());
+ file.close();
+ file.remove();
+ return result;
+}
+
+bool CeTcpSyncConnection::fileCreationTime(const QString &fileName, FILETIME* deviceCreationTime) const
+{
+ QString cmd = ceTcpSyncProgram + " fileCreationTime \"" + fileName + "\" >qt_cetcpsyncdata.txt";
+ if (system(qPrintable(cmd)) != 0)
+ return false;
+
+ QFile file("qt_cetcpsyncdata.txt");
+ if (!file.open(QIODevice::ReadOnly))
+ return false;
+
+ bool result = fileTimeFromString(*deviceCreationTime, file.readLine());
+ file.close();
+ file.remove();
+ return result;
+}
diff --git a/tools/qtestlib/wince/cetest/cetcpsyncconnection.h b/tools/qtestlib/wince/cetest/cetcpsyncconnection.h
new file mode 100644
index 0000000..1ef8423
--- /dev/null
+++ b/tools/qtestlib/wince/cetest/cetcpsyncconnection.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the tools applications 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CETCPSYNC_REMOTECONNECTION_H
+#define CETCPSYNC_REMOTECONNECTION_H
+
+#include "remoteconnection.h"
+
+class CeTcpSyncConnection : public AbstractRemoteConnection
+{
+public:
+ CeTcpSyncConnection();
+ virtual ~CeTcpSyncConnection();
+
+ bool connect(QVariantList &list = QVariantList());
+ void disconnect();
+ bool isConnected() const;
+
+ // These functions are designed for transfer between desktop and device
+ // Caution: deviceDest path has to be device specific (eg. no drive letters for CE)
+ bool copyFileToDevice(const QString &localSource, const QString &deviceDest, bool failIfExists = false);
+ bool copyDirectoryToDevice(const QString &localSource, const QString &deviceDest, bool recursive = true);
+ bool copyFileFromDevice(const QString &deviceSource, const QString &localDest, bool failIfExists = false);
+ bool copyDirectoryFromDevice(const QString &deviceSource, const QString &localDest, bool recursive = true);
+
+ bool timeStampForLocalFileTime(FILETIME*) const;
+ bool fileCreationTime(const QString &fileName, FILETIME*) const;
+
+ // These functions only work on files existing on the device
+ bool copyFile(const QString&, const QString&, bool failIfExists = false);
+ bool copyDirectory(const QString&, const QString&, bool recursive = true);
+ bool deleteFile(const QString&);
+ bool deleteDirectory(const QString&, bool recursive = true, bool failIfContentExists = false);
+ bool moveFile(const QString&, const QString&, bool FailIfExists = false);
+ bool moveDirectory(const QString&, const QString&, bool recursive = true);
+
+ bool createDirectory(const QString&, bool deleteBefore=false);
+
+ bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL);
+private:
+ bool connected;
+};
+
+#endif
diff --git a/tools/qtestlib/wince/cetest/cetest.pro b/tools/qtestlib/wince/cetest/cetest.pro
index d66fa33..a6b79da 100644
--- a/tools/qtestlib/wince/cetest/cetest.pro
+++ b/tools/qtestlib/wince/cetest/cetest.pro
@@ -28,20 +28,27 @@ DEPENDPATH += $$QT_BUILD_TREE/src/corelib/tools $$QT_BUILD_TREE/src/corelib/io
# Input
HEADERS += \
remoteconnection.h \
- activesyncconnection.h \
deployment.h
SOURCES += \
remoteconnection.cpp \
- activesyncconnection.cpp \
deployment.cpp \
main.cpp
-win32-msvc*:LIBS += ole32.lib advapi32.lib rapi.lib
+LIBS += ole32.lib advapi32.lib
+
+isEmpty(QT_CE_RAPI_INC) {
+ DEFINES += QT_CETEST_NO_ACTIVESYNC
+ HEADERS += cetcpsyncconnection.h
+ SOURCES += cetcpsyncconnection.cpp
+} else {
+ HEADERS += activesyncconnection.h
+ SOURCES += activesyncconnection.cpp
+ LIBS += rapi.lib
+ INCLUDEPATH += $$QT_CE_RAPI_INC
+ LIBS += -L$$QT_CE_RAPI_LIB
+}
include(qmake_include.pri)
include(bootstrapped.pri)
include($$QT_SOURCE_TREE/src/script/script.pri)
-
-INCLUDEPATH += $$QT_CE_RAPI_INC
-LIBS += -L$$QT_CE_RAPI_LIB
diff --git a/tools/qtestlib/wince/cetest/deployment.cpp b/tools/qtestlib/wince/cetest/deployment.cpp
index 68f0197..c64ae26 100644
--- a/tools/qtestlib/wince/cetest/deployment.cpp
+++ b/tools/qtestlib/wince/cetest/deployment.cpp
@@ -168,6 +168,7 @@ void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &depl
}
}
+#ifndef QT_CETEST_NO_ACTIVESYNC
// QtRemote deployment. We always deploy to \Windows
if (!project->values("QMAKE_LIBDIR").isEmpty()) {
QString remoteLibName = QLatin1String("QtRemote.dll");
@@ -177,6 +178,7 @@ void DeploymentHandler::initQtDeploy(QMakeProject *project, DeploymentList &depl
else
debugOutput(QString::fromLatin1("Could not find QtRemote. Might not be able to launch target executable"),0);
}
+#endif
// C-runtime deployment
QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1String(" "));
diff --git a/tools/qtestlib/wince/cetest/main.cpp b/tools/qtestlib/wince/cetest/main.cpp
index 782f6d9..e0e475c 100644
--- a/tools/qtestlib/wince/cetest/main.cpp
+++ b/tools/qtestlib/wince/cetest/main.cpp
@@ -39,7 +39,12 @@
**
****************************************************************************/
-#include "activesyncconnection.h"
+#ifdef QT_CETEST_NO_ACTIVESYNC
+# include "cetcpsyncconnection.h"
+#else
+# include "activesyncconnection.h"
+#endif
+
#include "deployment.h"
#include <option.h>
#include <project.h>
@@ -290,7 +295,11 @@ int main(int argc, char **argv)
projectDeploymentList.append(CopyItem(TestConfiguration::localExecutable , TestConfiguration::remoteExecutable));
// deploy
+#ifdef QT_CETEST_NO_ACTIVESYNC
+ CeTcpSyncConnection connection;
+#else
ActiveSyncConnection connection;
+#endif
if (!connection.connect()) {
cout << "Error: Could not connect to device!" << endl;
return -1;