From 0ad37ee268f4a314ee31e70fc8b4acfc9aa46970 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 7 Sep 2009 16:16:49 +0100 Subject: Refactored object tree dumping framework into a separate DLL --- src/3rdparty/phonon/mmf/objectdump.cpp | 527 --------------------- src/3rdparty/phonon/mmf/objectdump.h | 164 ------- src/3rdparty/phonon/mmf/objectdump/objectdump.cpp | 527 +++++++++++++++++++++ src/3rdparty/phonon/mmf/objectdump/objectdump.h | 166 +++++++ .../phonon/mmf/objectdump/objectdump_global.h | 30 ++ .../phonon/mmf/objectdump/objectdump_stub.cpp | 40 ++ .../phonon/mmf/objectdump/objectdump_symbian.cpp | 129 +++++ .../phonon/mmf/objectdump/objectdump_symbian.h | 56 +++ src/3rdparty/phonon/mmf/objectdump/objecttree.cpp | 102 ++++ src/3rdparty/phonon/mmf/objectdump/objecttree.h | 117 +++++ src/3rdparty/phonon/mmf/objectdump_symbian.cpp | 129 ----- src/3rdparty/phonon/mmf/objectdump_symbian.h | 56 --- src/3rdparty/phonon/mmf/objecttree.cpp | 102 ---- src/3rdparty/phonon/mmf/objecttree.h | 115 ----- src/3rdparty/phonon/mmf/videooutput.cpp | 2 +- src/3rdparty/phonon/mmf/videoplayer.cpp | 2 +- src/plugins/phonon/mmf/mmf.pro | 90 +--- src/plugins/phonon/mmf/objectdump/objectdump.pro | 28 ++ src/plugins/phonon/mmf/plugin/plugin.pro | 79 +++ 19 files changed, 1278 insertions(+), 1183 deletions(-) delete mode 100644 src/3rdparty/phonon/mmf/objectdump.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_global.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h create mode 100644 src/3rdparty/phonon/mmf/objectdump/objecttree.cpp create mode 100644 src/3rdparty/phonon/mmf/objectdump/objecttree.h delete mode 100644 src/3rdparty/phonon/mmf/objectdump_symbian.cpp delete mode 100644 src/3rdparty/phonon/mmf/objectdump_symbian.h delete mode 100644 src/3rdparty/phonon/mmf/objecttree.cpp delete mode 100644 src/3rdparty/phonon/mmf/objecttree.h create mode 100644 src/plugins/phonon/mmf/objectdump/objectdump.pro create mode 100644 src/plugins/phonon/mmf/plugin/plugin.pro diff --git a/src/3rdparty/phonon/mmf/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump.cpp deleted file mode 100644 index 50c6bf8..0000000 --- a/src/3rdparty/phonon/mmf/objectdump.cpp +++ /dev/null @@ -1,527 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#include -#include -#include -#include -#include - -#include "objectdump.h" -#include "objecttree.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -//----------------------------------------------------------------------------- -// QObjectAnnotator -//----------------------------------------------------------------------------- - -QAnnotator::~QAnnotator() -{ - -} - - -//----------------------------------------------------------------------------- -// Annotators -//----------------------------------------------------------------------------- - -QList QAnnotatorBasic::annotation(const QObject& object) -{ - QList result; - - QByteArray array; - QTextStream stream(&array); - - stream << '[' << &object << ']'; - stream << ' '; - stream << object.metaObject()->className(); - - if(object.objectName() != "") - stream << " \"" << object.objectName() << '"'; - - if(object.isWidgetType()) - stream << " isWidget"; - - stream.flush(); - result.append(array); - return result; -} - -QList QAnnotatorWidget::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - QByteArray array; - QTextStream stream(&array); - - stream << "widget: "; - - if(widget->isVisible()) - stream << "visible "; - else - stream << "invisible "; - - stream << widget->x() << ',' << widget->y() << ' '; - stream << widget->size().width() << 'x'<< widget->size().height() << ' '; - - stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); - - stream.flush(); - result.append(array); - } - - return result; -} - - -//----------------------------------------------------------------------------- -// Base class for QDumperPrivate, QVisitorPrivate -//----------------------------------------------------------------------------- - -class QDumperBase -{ -public: - QDumperBase(); - ~QDumperBase(); - - void setPrefix(const QString& prefix); - void addAnnotator(QAnnotator* annotator); - -protected: - QByteArray m_prefix; - QList m_annotators; - -}; - -QDumperBase::QDumperBase() -{ - -} - -QDumperBase::~QDumperBase() -{ - QAnnotator* annotator; - foreach(annotator, m_annotators) - delete annotator; -} - -void QDumperBase::setPrefix(const QString& prefix) -{ - m_prefix = prefix.count() - ? (prefix + " ").toAscii() - : prefix.toAscii(); -} - -void QDumperBase::addAnnotator(QAnnotator* annotator) -{ - // Protect against an exception occurring during QList::append - QScopedPointer holder(annotator); - m_annotators.append(annotator); - holder.take(); -} - - -//----------------------------------------------------------------------------- -// QDumper -//----------------------------------------------------------------------------- - -class QDumperPrivate : public QDumperBase -{ -public: - QDumperPrivate(); - ~QDumperPrivate(); - - void dumpObject(const QObject& object); - -}; - - -QDumperPrivate::QDumperPrivate() -{ - -} - -QDumperPrivate::~QDumperPrivate() -{ - -} - -void QDumperPrivate::dumpObject(const QObject& object) -{ - QAnnotator* annotator; - foreach(annotator, m_annotators) { - - const QList annotations = annotator->annotation(object); - QByteArray annotation; - foreach(annotation, annotations) { - QByteArray buffer(m_prefix); - buffer.append(annotation); - qDebug() << buffer.constData(); - } - } -} - - -QDumper::QDumper() - : d_ptr(new QDumperPrivate) -{ - -} - -QDumper::~QDumper() -{ - -} - -void QDumper::setPrefix(const QString& prefix) -{ - d_func()->setPrefix(prefix); -} - -void QDumper::addAnnotator(QAnnotator* annotator) -{ - d_func()->addAnnotator(annotator); -} - -void QDumper::dumpObject(const QObject& object) -{ - d_func()->dumpObject(object); -} - - -//----------------------------------------------------------------------------- -// QVisitor -//----------------------------------------------------------------------------- - -class QVisitorPrivate : public QDumperBase -{ -public: - QVisitorPrivate(); - ~QVisitorPrivate(); - - void setIndent(unsigned indent); - - void visitNode(const QObject& object); - void visitComplete(); - -private: - class Node - { - public: - Node(); - ~Node(); - - QList m_annotation; - QList m_children; - - typedef QList::const_iterator child_iterator; - }; - -private: - Node* findNode(const QObject* object) const; - QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; - void dumpRecursive(const Node& node, QList branches, bool isLastChild); - void dumpNode(const Node& node, const QList& branches, bool isLastChild); - -private: - unsigned m_indent; - - QScopedPointer m_root; - - // Hash table used to associate internal nodes with QObjects - typedef QHash Hash; - Hash m_hash; -}; - -static const unsigned DefaultIndent = 2; - -QVisitorPrivate::QVisitorPrivate() - : m_indent(DefaultIndent) -{ - -} - -QVisitorPrivate::~QVisitorPrivate() -{ - -} - -void QVisitorPrivate::setIndent(unsigned indent) -{ - m_indent = indent; -} - -// Builds up a mirror of the object tree, rooted in m_root, with each node -// storing annotations generated by -void QVisitorPrivate::visitNode(const QObject& object) -{ - QObject* const objectParent = object.parent(); - Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; - - // Create a new node and store in scoped pointer for exception safety - Node* node = new Node; - QScopedPointer nodePtr(node); - - // Associate node with QObject - m_hash.insert(&object, node); - - // Insert node into internal tree - if(nodeParent) - { - nodeParent->m_children.append(nodePtr.take()); - } - else - { - Q_ASSERT(m_root.isNull()); - m_root.reset(nodePtr.take()); - } - - // Generate and store annotations - QAnnotator* annotator; - foreach(annotator, m_annotators) - node->m_annotation.append( annotator->annotation(object) ); -} - -void QVisitorPrivate::visitComplete() -{ - QList branches; - static const bool isLastChild = true; - dumpRecursive(*m_root, branches, isLastChild); - m_root.reset(NULL); -} - -QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const -{ - Hash::const_iterator i = m_hash.find(object); - return (m_hash.end() == i) ? NULL : *i; -} - -QByteArray QVisitorPrivate::branchBuffer - (const QList& branches, bool isNodeLine, bool isLastChild) const -{ - const int depth = branches.count(); - - const QByteArray indent(m_indent, ' '); - const QByteArray horiz(m_indent, '-'); - - QByteArray buffer; - QTextStream stream(&buffer); - - for (int i=0; i branches, bool isLastChild) -{ - dumpNode(node, branches, isLastChild); - - // Recurse down tree - const Node::child_iterator begin = node.m_children.begin(); - const Node::child_iterator end = node.m_children.end(); - for(Node::child_iterator i = begin; end != i; ++i) { - - isLastChild = (end == i + 1); - - if(begin == i) - branches.push_back(!isLastChild); - else - branches.back() = !isLastChild; - - static const bool isNodeLine = false; - const QByteArray buffer = branchBuffer(branches, isNodeLine, false); - qDebug() << buffer.constData(); - - dumpRecursive(**i, branches, isLastChild); - } -} - -void QVisitorPrivate::dumpNode - (const Node& node, const QList& branches, bool isLastChild) -{ - const QList::const_iterator - begin = node.m_annotation.begin(), end = node.m_annotation.end(); - - if(begin == end) { - // No annotations - just dump the object pointer - const bool isNodeLine = true; - QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - qDebug() << NULL; // TODO - } - else { - // Dump annotations - for(QList::const_iterator i = begin; end != i; ++i) { - const bool isNodeLine = (begin == i); - QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); - buffer.append(*i); - qDebug() << buffer.constData(); - } - } -} - - -// QVisitorPrivate::Node - -QVisitorPrivate::Node::Node() -{ - -} - -QVisitorPrivate::Node::~Node() -{ - Node* child; - foreach(child, m_children) - delete child; -} - - -// QVisitor - -QVisitor::QVisitor() - : d_ptr(new QVisitorPrivate) -{ - -} - -QVisitor::~QVisitor() -{ - -} - -void QVisitor::setPrefix(const QString& prefix) -{ - d_func()->setPrefix(prefix); -} - -void QVisitor::setIndent(unsigned indent) -{ - d_func()->setIndent(indent); -} - -void QVisitor::addAnnotator(QAnnotator* annotator) -{ - d_func()->addAnnotator(annotator); -} - -void QVisitor::visitPrepare() -{ - // Do nothing -} - -void QVisitor::visitNode(const QObject& object) -{ - d_func()->visitNode(object); -} - -void QVisitor::visitComplete() -{ - d_func()->visitComplete(); -} - - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -void addDefaultAnnotators_sys(QDumper& visitor); -void addDefaultAnnotators_sys(QVisitor& visitor); - -void addDefaultAnnotators(QDumper& dumper) -{ - dumper.addAnnotator(new QAnnotatorBasic); - dumper.addAnnotator(new QAnnotatorWidget); - - // Add platform-specific annotators - addDefaultAnnotators_sys(dumper); -} - -void addDefaultAnnotators(QVisitor& visitor) -{ - visitor.addAnnotator(new QAnnotatorBasic); - visitor.addAnnotator(new QAnnotatorWidget); - - // Add platform-specific annotators - addDefaultAnnotators_sys(visitor); -} - -void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) -{ - // Set up iteration range - ObjectTree::DepthFirstConstIterator begin(root), end; - - // Invoke generic visitor algorithm - ObjectTree::visit(begin, end, visitor); -} - -void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) -{ - // Walk up to root - const QObject* root = &leaf; - while(root->parent()) - { - root = root->parent(); - } - - dumpTreeFromRoot(*root, visitor); -} - -void dumpAncestors(const QObject& leaf, QVisitor& visitor) -{ - // Set up iteration range - ObjectTree::AncestorConstIterator begin(leaf), end; - - // Invoke generic visitor algorithm - ObjectTree::visit(begin, end, visitor); -} - - -} // namespace ObjectDump - -QT_END_NAMESPACE - - - diff --git a/src/3rdparty/phonon/mmf/objectdump.h b/src/3rdparty/phonon/mmf/objectdump.h deleted file mode 100644 index 4efc015..0000000 --- a/src/3rdparty/phonon/mmf/objectdump.h +++ /dev/null @@ -1,164 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#ifndef OBJECTDUMP_H -#define OBJECTDUMP_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ - -/** - * Abstract base for annotator classes invoked by QVisitor. - */ -class QAnnotator : public QObject -{ - Q_OBJECT -public: - virtual ~QAnnotator(); - virtual QList annotation(const QObject& object) = 0; -}; - -/** - * Annotator which replicates QObject::dumpObjectTree functionality. - */ -class QAnnotatorBasic : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -/** - * Annotator which returns widget information. - */ -class QAnnotatorWidget : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - - -class QDumperPrivate; - -/** - * Class used to dump information about individual QObjects. - */ -class QDumper : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDumper) - -public: - QDumper(); - ~QDumper(); - - /** - * Specify a prefix, to be printed on each line of output. - */ - void setPrefix(const QString& prefix); - - /** - * Takes ownership of annotator. - */ - void addAnnotator(QAnnotator* annotator); - - /** - * Invoke each annotator on the object and write to debug output. - */ - void dumpObject(const QObject& object); - -private: - QScopedPointer d_ptr; - -}; - - -class QVisitorPrivate; - -/** - * Visitor class which dumps information about nodes in the object tree. - */ -class QVisitor : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QVisitor) - -public: - QVisitor(); - ~QVisitor(); - - /** - * Specify a prefix, to be printed on each line of output. - */ - void setPrefix(const QString& prefix); - - /** - * Set number of spaces by which each level of the tree is indented. - */ - void setIndent(unsigned indent); - - /** - * Called by the visitor algorithm before starting the visit. - */ - void visitPrepare(); - - /** - * Called by the visitor algorithm as each node is visited. - */ - void visitNode(const QObject& object); - - /** - * Called by the visitor algorithm when the visit is complete. - */ - void visitComplete(); - - /** - * Takes ownership of annotator. - */ - void addAnnotator(QAnnotator* annotator); - -private: - QScopedPointer d_ptr; - -}; - - -//----------------------------------------------------------------------------- -// Utility functions -//----------------------------------------------------------------------------- - -void addDefaultAnnotators(QDumper& dumper); -void addDefaultAnnotators(QVisitor& visitor); - -void dumpTreeFromRoot(const QObject& root, QVisitor& visitor); -void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); -void dumpAncestors(const QObject& leaf, QVisitor& visitor); - -} // namespace ObjectDump - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp new file mode 100644 index 0000000..50c6bf8 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump.cpp @@ -0,0 +1,527 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include +#include +#include +#include + +#include "objectdump.h" +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +//----------------------------------------------------------------------------- +// QObjectAnnotator +//----------------------------------------------------------------------------- + +QAnnotator::~QAnnotator() +{ + +} + + +//----------------------------------------------------------------------------- +// Annotators +//----------------------------------------------------------------------------- + +QList QAnnotatorBasic::annotation(const QObject& object) +{ + QList result; + + QByteArray array; + QTextStream stream(&array); + + stream << '[' << &object << ']'; + stream << ' '; + stream << object.metaObject()->className(); + + if(object.objectName() != "") + stream << " \"" << object.objectName() << '"'; + + if(object.isWidgetType()) + stream << " isWidget"; + + stream.flush(); + result.append(array); + return result; +} + +QList QAnnotatorWidget::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + QByteArray array; + QTextStream stream(&array); + + stream << "widget: "; + + if(widget->isVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << widget->x() << ',' << widget->y() << ' '; + stream << widget->size().width() << 'x'<< widget->size().height() << ' '; + + stream << "hint " << widget->sizeHint().width() << 'x' << widget->sizeHint().height(); + + stream.flush(); + result.append(array); + } + + return result; +} + + +//----------------------------------------------------------------------------- +// Base class for QDumperPrivate, QVisitorPrivate +//----------------------------------------------------------------------------- + +class QDumperBase +{ +public: + QDumperBase(); + ~QDumperBase(); + + void setPrefix(const QString& prefix); + void addAnnotator(QAnnotator* annotator); + +protected: + QByteArray m_prefix; + QList m_annotators; + +}; + +QDumperBase::QDumperBase() +{ + +} + +QDumperBase::~QDumperBase() +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) + delete annotator; +} + +void QDumperBase::setPrefix(const QString& prefix) +{ + m_prefix = prefix.count() + ? (prefix + " ").toAscii() + : prefix.toAscii(); +} + +void QDumperBase::addAnnotator(QAnnotator* annotator) +{ + // Protect against an exception occurring during QList::append + QScopedPointer holder(annotator); + m_annotators.append(annotator); + holder.take(); +} + + +//----------------------------------------------------------------------------- +// QDumper +//----------------------------------------------------------------------------- + +class QDumperPrivate : public QDumperBase +{ +public: + QDumperPrivate(); + ~QDumperPrivate(); + + void dumpObject(const QObject& object); + +}; + + +QDumperPrivate::QDumperPrivate() +{ + +} + +QDumperPrivate::~QDumperPrivate() +{ + +} + +void QDumperPrivate::dumpObject(const QObject& object) +{ + QAnnotator* annotator; + foreach(annotator, m_annotators) { + + const QList annotations = annotator->annotation(object); + QByteArray annotation; + foreach(annotation, annotations) { + QByteArray buffer(m_prefix); + buffer.append(annotation); + qDebug() << buffer.constData(); + } + } +} + + +QDumper::QDumper() + : d_ptr(new QDumperPrivate) +{ + +} + +QDumper::~QDumper() +{ + +} + +void QDumper::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QDumper::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QDumper::dumpObject(const QObject& object) +{ + d_func()->dumpObject(object); +} + + +//----------------------------------------------------------------------------- +// QVisitor +//----------------------------------------------------------------------------- + +class QVisitorPrivate : public QDumperBase +{ +public: + QVisitorPrivate(); + ~QVisitorPrivate(); + + void setIndent(unsigned indent); + + void visitNode(const QObject& object); + void visitComplete(); + +private: + class Node + { + public: + Node(); + ~Node(); + + QList m_annotation; + QList m_children; + + typedef QList::const_iterator child_iterator; + }; + +private: + Node* findNode(const QObject* object) const; + QByteArray branchBuffer(const QList& branches, bool isNodeLine, bool isLastChild) const; + void dumpRecursive(const Node& node, QList branches, bool isLastChild); + void dumpNode(const Node& node, const QList& branches, bool isLastChild); + +private: + unsigned m_indent; + + QScopedPointer m_root; + + // Hash table used to associate internal nodes with QObjects + typedef QHash Hash; + Hash m_hash; +}; + +static const unsigned DefaultIndent = 2; + +QVisitorPrivate::QVisitorPrivate() + : m_indent(DefaultIndent) +{ + +} + +QVisitorPrivate::~QVisitorPrivate() +{ + +} + +void QVisitorPrivate::setIndent(unsigned indent) +{ + m_indent = indent; +} + +// Builds up a mirror of the object tree, rooted in m_root, with each node +// storing annotations generated by +void QVisitorPrivate::visitNode(const QObject& object) +{ + QObject* const objectParent = object.parent(); + Node* const nodeParent = objectParent ? findNode(objectParent) : NULL; + + // Create a new node and store in scoped pointer for exception safety + Node* node = new Node; + QScopedPointer nodePtr(node); + + // Associate node with QObject + m_hash.insert(&object, node); + + // Insert node into internal tree + if(nodeParent) + { + nodeParent->m_children.append(nodePtr.take()); + } + else + { + Q_ASSERT(m_root.isNull()); + m_root.reset(nodePtr.take()); + } + + // Generate and store annotations + QAnnotator* annotator; + foreach(annotator, m_annotators) + node->m_annotation.append( annotator->annotation(object) ); +} + +void QVisitorPrivate::visitComplete() +{ + QList branches; + static const bool isLastChild = true; + dumpRecursive(*m_root, branches, isLastChild); + m_root.reset(NULL); +} + +QVisitorPrivate::Node* QVisitorPrivate::findNode(const QObject* object) const +{ + Hash::const_iterator i = m_hash.find(object); + return (m_hash.end() == i) ? NULL : *i; +} + +QByteArray QVisitorPrivate::branchBuffer + (const QList& branches, bool isNodeLine, bool isLastChild) const +{ + const int depth = branches.count(); + + const QByteArray indent(m_indent, ' '); + const QByteArray horiz(m_indent, '-'); + + QByteArray buffer; + QTextStream stream(&buffer); + + for (int i=0; i branches, bool isLastChild) +{ + dumpNode(node, branches, isLastChild); + + // Recurse down tree + const Node::child_iterator begin = node.m_children.begin(); + const Node::child_iterator end = node.m_children.end(); + for(Node::child_iterator i = begin; end != i; ++i) { + + isLastChild = (end == i + 1); + + if(begin == i) + branches.push_back(!isLastChild); + else + branches.back() = !isLastChild; + + static const bool isNodeLine = false; + const QByteArray buffer = branchBuffer(branches, isNodeLine, false); + qDebug() << buffer.constData(); + + dumpRecursive(**i, branches, isLastChild); + } +} + +void QVisitorPrivate::dumpNode + (const Node& node, const QList& branches, bool isLastChild) +{ + const QList::const_iterator + begin = node.m_annotation.begin(), end = node.m_annotation.end(); + + if(begin == end) { + // No annotations - just dump the object pointer + const bool isNodeLine = true; + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + qDebug() << NULL; // TODO + } + else { + // Dump annotations + for(QList::const_iterator i = begin; end != i; ++i) { + const bool isNodeLine = (begin == i); + QByteArray buffer = branchBuffer(branches, isNodeLine, isLastChild); + buffer.append(*i); + qDebug() << buffer.constData(); + } + } +} + + +// QVisitorPrivate::Node + +QVisitorPrivate::Node::Node() +{ + +} + +QVisitorPrivate::Node::~Node() +{ + Node* child; + foreach(child, m_children) + delete child; +} + + +// QVisitor + +QVisitor::QVisitor() + : d_ptr(new QVisitorPrivate) +{ + +} + +QVisitor::~QVisitor() +{ + +} + +void QVisitor::setPrefix(const QString& prefix) +{ + d_func()->setPrefix(prefix); +} + +void QVisitor::setIndent(unsigned indent) +{ + d_func()->setIndent(indent); +} + +void QVisitor::addAnnotator(QAnnotator* annotator) +{ + d_func()->addAnnotator(annotator); +} + +void QVisitor::visitPrepare() +{ + // Do nothing +} + +void QVisitor::visitNode(const QObject& object) +{ + d_func()->visitNode(object); +} + +void QVisitor::visitComplete() +{ + d_func()->visitComplete(); +} + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void addDefaultAnnotators_sys(QDumper& visitor); +void addDefaultAnnotators_sys(QVisitor& visitor); + +void addDefaultAnnotators(QDumper& dumper) +{ + dumper.addAnnotator(new QAnnotatorBasic); + dumper.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(dumper); +} + +void addDefaultAnnotators(QVisitor& visitor) +{ + visitor.addAnnotator(new QAnnotatorBasic); + visitor.addAnnotator(new QAnnotatorWidget); + + // Add platform-specific annotators + addDefaultAnnotators_sys(visitor); +} + +void dumpTreeFromRoot(const QObject& root, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::DepthFirstConstIterator begin(root), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + +void dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor) +{ + // Walk up to root + const QObject* root = &leaf; + while(root->parent()) + { + root = root->parent(); + } + + dumpTreeFromRoot(*root, visitor); +} + +void dumpAncestors(const QObject& leaf, QVisitor& visitor) +{ + // Set up iteration range + ObjectTree::AncestorConstIterator begin(leaf), end; + + // Invoke generic visitor algorithm + ObjectTree::visit(begin, end, visitor); +} + + +} // namespace ObjectDump + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump.h b/src/3rdparty/phonon/mmf/objectdump/objectdump.h new file mode 100644 index 0000000..cbd9bea --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump.h @@ -0,0 +1,166 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef OBJECTDUMP_H +#define OBJECTDUMP_H + +#include "objectdump_global.h" + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +/** + * Abstract base for annotator classes invoked by QVisitor. + */ +class OBJECTDUMP_EXPORT QAnnotator : public QObject +{ + Q_OBJECT +public: + virtual ~QAnnotator(); + virtual QList annotation(const QObject& object) = 0; +}; + +/** + * Annotator which replicates QObject::dumpObjectTree functionality. + */ +class OBJECTDUMP_EXPORT QAnnotatorBasic : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns widget information. + */ +class OBJECTDUMP_EXPORT QAnnotatorWidget : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + + +class QDumperPrivate; + +/** + * Class used to dump information about individual QObjects. + */ +class OBJECTDUMP_EXPORT QDumper : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QDumper) + +public: + QDumper(); + ~QDumper(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + + /** + * Invoke each annotator on the object and write to debug output. + */ + void dumpObject(const QObject& object); + +private: + QScopedPointer d_ptr; + +}; + + +class QVisitorPrivate; + +/** + * Visitor class which dumps information about nodes in the object tree. + */ +class OBJECTDUMP_EXPORT QVisitor : public QObject +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QVisitor) + +public: + QVisitor(); + ~QVisitor(); + + /** + * Specify a prefix, to be printed on each line of output. + */ + void setPrefix(const QString& prefix); + + /** + * Set number of spaces by which each level of the tree is indented. + */ + void setIndent(unsigned indent); + + /** + * Called by the visitor algorithm before starting the visit. + */ + void visitPrepare(); + + /** + * Called by the visitor algorithm as each node is visited. + */ + void visitNode(const QObject& object); + + /** + * Called by the visitor algorithm when the visit is complete. + */ + void visitComplete(); + + /** + * Takes ownership of annotator. + */ + void addAnnotator(QAnnotator* annotator); + +private: + QScopedPointer d_ptr; + +}; + + +//----------------------------------------------------------------------------- +// Utility functions +//----------------------------------------------------------------------------- + +void OBJECTDUMP_EXPORT addDefaultAnnotators(QDumper& dumper); +void OBJECTDUMP_EXPORT addDefaultAnnotators(QVisitor& visitor); + +void OBJECTDUMP_EXPORT dumpTreeFromRoot(const QObject& root, QVisitor& visitor); +void OBJECTDUMP_EXPORT dumpTreeFromLeaf(const QObject& leaf, QVisitor& visitor); +void OBJECTDUMP_EXPORT dumpAncestors(const QObject& leaf, QVisitor& visitor); + +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h b/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h new file mode 100644 index 0000000..ff031c4 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_global.h @@ -0,0 +1,30 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef OBJECTDUMP_GLOBAL_H +#define OBJECTDUMP_GLOBAL_H + +#include + +#if defined(OBJECTDUMP_LIBRARY) +# define OBJECTDUMP_EXPORT Q_DECL_EXPORT +#else +# define OBJECTDUMP_EXPORT Q_DECL_IMPORT +#endif + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp new file mode 100644 index 0000000..6207dac --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_stub.cpp @@ -0,0 +1,40 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ + +void addDefaultAnnotators_sys(QDumper& /*dumper*/) +{ + +} + +void addDefaultAnnotators_sys(QVisitor& /*visitor*/) +{ + +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp new file mode 100644 index 0000000..54ebc55 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.cpp @@ -0,0 +1,129 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include +#include +#include "objectdump_symbian.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +QList QAnnotatorControl::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + QByteArray array; + QTextStream stream(&array); + + stream << "control: " << control << ' '; + stream << "parent " << control->Parent() << ' '; + + if(control->IsVisible()) + stream << "visible "; + else + stream << "invisible "; + + stream << control->Position().iX << ',' << control->Position().iY << ' '; + stream << control->Size().iWidth << 'x' << control->Size().iHeight; + + if(control->OwnsWindow()) + stream << " ownsWindow "; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +QList QAnnotatorWindow::annotation(const QObject& object) +{ + QList result; + + const QWidget* widget = qobject_cast(&object); + if(widget) { + + const CCoeControl* control = widget->effectiveWinId(); + if(control) { + + RDrawableWindow& window = *(control->DrawableWindow()); + + QByteArray array; + QTextStream stream(&array); + + stream << "window: "; + + // Client-side window handle + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; + + // Server-side address of CWsWindow object + // This is useful for correlation with the window tree dumped by the window + // server (see RWsSession::LogCommand). + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; + + stream << "group " << window.WindowGroupId() << ' '; + + // Client-side handle to the parent window. + // Cast to a void pointer so that log output is in hexadecimal format. + stream << "parent " << reinterpret_cast(window.Parent()) << ' '; + + stream << window.Position().iX << ',' << window.Position().iY << ' '; + stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; + stream << window.Size().iWidth << 'x' << window.Size().iHeight; + + stream.flush(); + result.append(array); + } + } + + return result; +} + +} // namespace Symbian + +void addDefaultAnnotators_sys(QDumper& dumper) +{ + dumper.addAnnotator(new Symbian::QAnnotatorControl); + dumper.addAnnotator(new Symbian::QAnnotatorWindow); +} + +void addDefaultAnnotators_sys(QVisitor& visitor) +{ + visitor.addAnnotator(new Symbian::QAnnotatorControl); + visitor.addAnnotator(new Symbian::QAnnotatorWindow); +} + +} // namespace ObjectDump + +QT_END_NAMESPACE + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h new file mode 100644 index 0000000..26ab308 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objectdump_symbian.h @@ -0,0 +1,56 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef OBJECTDUMP_SYMBIAN_H +#define OBJECTDUMP_SYMBIAN_H + +#include "objectdump.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectDump +{ +namespace Symbian +{ + +/** + * Annotator which returns control information + */ +class QAnnotatorControl : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +/** + * Annotator which returns window information + */ +class QAnnotatorWindow : public QAnnotator +{ + Q_OBJECT +public: + QList annotation(const QObject& object); +}; + +} // namespace Symbian +} // namespace ObjectDump + +QT_END_NAMESPACE + +#endif diff --git a/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp b/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp new file mode 100644 index 0000000..f9d1c93 --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objecttree.cpp @@ -0,0 +1,102 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include +#include +#include "objecttree.h" + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +DepthFirstConstIterator::DepthFirstConstIterator() + : m_pointee(NULL) +{ + +} + +DepthFirstConstIterator::DepthFirstConstIterator + (const QObject& root) + : m_pointee(&root) +{ + +} + +DepthFirstConstIterator& + DepthFirstConstIterator::operator++() +{ + const QObjectList& children = m_pointee->children(); + + if (children.count() == 0) { + backtrack(); + } + else { + m_history.push(0); + m_pointee = children.first(); + } + + return *this; +} + +void DepthFirstConstIterator::backtrack() +{ + if (m_history.count()) { + const int index = m_history.top(); + m_history.pop(); + + const QObjectList& siblings = m_pointee->parent()->children(); + if (siblings.count() > index + 1) { + m_history.push(index + 1); + m_pointee = siblings[index + 1]; + } + else { + m_pointee = m_pointee->parent(); + backtrack(); + } + } + else { + // Reached end of search + m_pointee = NULL; + } +} + + + +AncestorConstIterator::AncestorConstIterator() +{ + +} + +AncestorConstIterator::AncestorConstIterator(const QObject& leaf) +{ + m_ancestors.push(&leaf); + QObject* ancestor = leaf.parent(); + while(ancestor) + { + m_ancestors.push(ancestor); + ancestor = ancestor->parent(); + } +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + + + diff --git a/src/3rdparty/phonon/mmf/objectdump/objecttree.h b/src/3rdparty/phonon/mmf/objectdump/objecttree.h new file mode 100644 index 0000000..f2729fa --- /dev/null +++ b/src/3rdparty/phonon/mmf/objectdump/objecttree.h @@ -0,0 +1,117 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef OBJECTTREE_H +#define OBJECTTREE_H + +#include "objectdump_global.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +namespace ObjectTree +{ + +/** + * Depth-first iterator for QObject tree + */ +class OBJECTDUMP_EXPORT DepthFirstConstIterator +{ +public: + DepthFirstConstIterator(); + DepthFirstConstIterator(const QObject& root); + + DepthFirstConstIterator& operator++(); + + inline bool operator==(const DepthFirstConstIterator& other) const + { return other.m_pointee == m_pointee; } + + inline bool operator!=(const DepthFirstConstIterator& other) const + { return other.m_pointee != m_pointee; } + + inline const QObject* operator->() const { return m_pointee; } + inline const QObject& operator*() const { return *m_pointee; } + +private: + void backtrack(); + +private: + const QObject* m_pointee; + QStack m_history; +}; + +/** + * Ancestor iterator for QObject tree + */ +class OBJECTDUMP_EXPORT AncestorConstIterator +{ +public: + AncestorConstIterator(); + AncestorConstIterator(const QObject& root); + + inline AncestorConstIterator& operator++() + { m_ancestors.pop(); return *this; } + + inline bool operator==(const AncestorConstIterator& other) const + { return other.m_ancestors == m_ancestors; } + + inline bool operator!=(const AncestorConstIterator& other) const + { return other.m_ancestors != m_ancestors; } + + inline const QObject* operator->() const { return m_ancestors.top(); } + inline const QObject& operator*() const { return *m_ancestors.top(); } + +private: + QStack m_ancestors; + +}; + +/** + * Generic algorithm for visiting nodes in an object tree. Nodes in the + * tree are visited in a const context, therefore they are not modified + * by this algorithm. + * + * Visitor must provide functions with the following signatures: + * + * Called before visit begins + * void visitPrepare() + * + * Called on each node visited + * void visitNode(const QObject& object) + * + * Called when visit is complete + * void visitComplete() + */ +template +void visit(Iterator begin, Iterator end, Visitor& visitor) +{ + visitor.visitPrepare(); + + for( ; begin != end; ++begin) + visitor.visitNode(*begin); + + visitor.visitComplete(); +} + +} // namespace ObjectTree + +QT_END_NAMESPACE + +#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp b/src/3rdparty/phonon/mmf/objectdump_symbian.cpp deleted file mode 100644 index 54ebc55..0000000 --- a/src/3rdparty/phonon/mmf/objectdump_symbian.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#include -#include -#include -#include "objectdump_symbian.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ -namespace Symbian -{ - -QList QAnnotatorControl::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - const CCoeControl* control = widget->effectiveWinId(); - if(control) { - - QByteArray array; - QTextStream stream(&array); - - stream << "control: " << control << ' '; - stream << "parent " << control->Parent() << ' '; - - if(control->IsVisible()) - stream << "visible "; - else - stream << "invisible "; - - stream << control->Position().iX << ',' << control->Position().iY << ' '; - stream << control->Size().iWidth << 'x' << control->Size().iHeight; - - if(control->OwnsWindow()) - stream << " ownsWindow "; - - stream.flush(); - result.append(array); - } - } - - return result; -} - -QList QAnnotatorWindow::annotation(const QObject& object) -{ - QList result; - - const QWidget* widget = qobject_cast(&object); - if(widget) { - - const CCoeControl* control = widget->effectiveWinId(); - if(control) { - - RDrawableWindow& window = *(control->DrawableWindow()); - - QByteArray array; - QTextStream stream(&array); - - stream << "window: "; - - // Client-side window handle - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "cli " << reinterpret_cast(window.ClientHandle()) << ' '; - - // Server-side address of CWsWindow object - // This is useful for correlation with the window tree dumped by the window - // server (see RWsSession::LogCommand). - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "srv " << reinterpret_cast(window.WsHandle()) << ' '; - - stream << "group " << window.WindowGroupId() << ' '; - - // Client-side handle to the parent window. - // Cast to a void pointer so that log output is in hexadecimal format. - stream << "parent " << reinterpret_cast(window.Parent()) << ' '; - - stream << window.Position().iX << ',' << window.Position().iY << ' '; - stream << '(' << window.AbsPosition().iX << ',' << window.AbsPosition().iY << ") "; - stream << window.Size().iWidth << 'x' << window.Size().iHeight; - - stream.flush(); - result.append(array); - } - } - - return result; -} - -} // namespace Symbian - -void addDefaultAnnotators_sys(QDumper& dumper) -{ - dumper.addAnnotator(new Symbian::QAnnotatorControl); - dumper.addAnnotator(new Symbian::QAnnotatorWindow); -} - -void addDefaultAnnotators_sys(QVisitor& visitor) -{ - visitor.addAnnotator(new Symbian::QAnnotatorControl); - visitor.addAnnotator(new Symbian::QAnnotatorWindow); -} - -} // namespace ObjectDump - -QT_END_NAMESPACE - - diff --git a/src/3rdparty/phonon/mmf/objectdump_symbian.h b/src/3rdparty/phonon/mmf/objectdump_symbian.h deleted file mode 100644 index 26ab308..0000000 --- a/src/3rdparty/phonon/mmf/objectdump_symbian.h +++ /dev/null @@ -1,56 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#ifndef OBJECTDUMP_SYMBIAN_H -#define OBJECTDUMP_SYMBIAN_H - -#include "objectdump.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectDump -{ -namespace Symbian -{ - -/** - * Annotator which returns control information - */ -class QAnnotatorControl : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -/** - * Annotator which returns window information - */ -class QAnnotatorWindow : public QAnnotator -{ - Q_OBJECT -public: - QList annotation(const QObject& object); -}; - -} // namespace Symbian -} // namespace ObjectDump - -QT_END_NAMESPACE - -#endif diff --git a/src/3rdparty/phonon/mmf/objecttree.cpp b/src/3rdparty/phonon/mmf/objecttree.cpp deleted file mode 100644 index f9d1c93..0000000 --- a/src/3rdparty/phonon/mmf/objecttree.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#include -#include -#include "objecttree.h" - -QT_BEGIN_NAMESPACE - -namespace ObjectTree -{ - -DepthFirstConstIterator::DepthFirstConstIterator() - : m_pointee(NULL) -{ - -} - -DepthFirstConstIterator::DepthFirstConstIterator - (const QObject& root) - : m_pointee(&root) -{ - -} - -DepthFirstConstIterator& - DepthFirstConstIterator::operator++() -{ - const QObjectList& children = m_pointee->children(); - - if (children.count() == 0) { - backtrack(); - } - else { - m_history.push(0); - m_pointee = children.first(); - } - - return *this; -} - -void DepthFirstConstIterator::backtrack() -{ - if (m_history.count()) { - const int index = m_history.top(); - m_history.pop(); - - const QObjectList& siblings = m_pointee->parent()->children(); - if (siblings.count() > index + 1) { - m_history.push(index + 1); - m_pointee = siblings[index + 1]; - } - else { - m_pointee = m_pointee->parent(); - backtrack(); - } - } - else { - // Reached end of search - m_pointee = NULL; - } -} - - - -AncestorConstIterator::AncestorConstIterator() -{ - -} - -AncestorConstIterator::AncestorConstIterator(const QObject& leaf) -{ - m_ancestors.push(&leaf); - QObject* ancestor = leaf.parent(); - while(ancestor) - { - m_ancestors.push(ancestor); - ancestor = ancestor->parent(); - } -} - -} // namespace ObjectTree - -QT_END_NAMESPACE - - - diff --git a/src/3rdparty/phonon/mmf/objecttree.h b/src/3rdparty/phonon/mmf/objecttree.h deleted file mode 100644 index 0c2031d..0000000 --- a/src/3rdparty/phonon/mmf/objecttree.h +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of the KDE project. - -Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). - -This library is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 2.1 or 3 of the License. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library. If not, see . - -*/ - -#ifndef OBJECTTREE_H -#define OBJECTTREE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -namespace ObjectTree -{ - -/** - * Depth-first iterator for QObject tree - */ -class DepthFirstConstIterator -{ -public: - DepthFirstConstIterator(); - DepthFirstConstIterator(const QObject& root); - - DepthFirstConstIterator& operator++(); - - inline bool operator==(const DepthFirstConstIterator& other) const - { return other.m_pointee == m_pointee; } - - inline bool operator!=(const DepthFirstConstIterator& other) const - { return other.m_pointee != m_pointee; } - - inline const QObject* operator->() const { return m_pointee; } - inline const QObject& operator*() const { return *m_pointee; } - -private: - void backtrack(); - -private: - const QObject* m_pointee; - QStack m_history; -}; - -/** - * Ancestor iterator for QObject tree - */ -class AncestorConstIterator -{ -public: - AncestorConstIterator(); - AncestorConstIterator(const QObject& root); - - inline AncestorConstIterator& operator++() - { m_ancestors.pop(); return *this; } - - inline bool operator==(const AncestorConstIterator& other) const - { return other.m_ancestors == m_ancestors; } - - inline bool operator!=(const AncestorConstIterator& other) const - { return other.m_ancestors != m_ancestors; } - - inline const QObject* operator->() const { return m_ancestors.top(); } - inline const QObject& operator*() const { return *m_ancestors.top(); } - -private: - QStack m_ancestors; - -}; - -/** - * Generic algorithm for visiting nodes in an object tree. Nodes in the - * tree are visited in a const context, therefore they are not modified - * by this algorithm. - * - * Visitor must provide functions with the following signatures: - * - * Called before visit begins - * void visitPrepare() - * - * Called on each node visited - * void visitNode(const QObject& object) - * - * Called when visit is complete - * void visitComplete() - */ -template -void visit(Iterator begin, Iterator end, Visitor& visitor) -{ - visitor.visitPrepare(); - - for( ; begin != end; ++begin) - visitor.visitNode(*begin); - - visitor.visitComplete(); -} - -} // namespace ObjectTree - -QT_END_NAMESPACE - -#endif // OBJECTTREE_H diff --git a/src/3rdparty/phonon/mmf/videooutput.cpp b/src/3rdparty/phonon/mmf/videooutput.cpp index 2544a97..3f14f19 100644 --- a/src/3rdparty/phonon/mmf/videooutput.cpp +++ b/src/3rdparty/phonon/mmf/videooutput.cpp @@ -21,7 +21,7 @@ along with this library. If not, see . #include "videooutputobserver.h" #ifdef _DEBUG -#include "objectdump.h" +#include "objectdump/objectdump.h" #endif #include diff --git a/src/3rdparty/phonon/mmf/videoplayer.cpp b/src/3rdparty/phonon/mmf/videoplayer.cpp index e8b792f..b4f3d35 100644 --- a/src/3rdparty/phonon/mmf/videoplayer.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer.cpp @@ -27,7 +27,7 @@ along with this library. If not, see . #include "utils.h" #ifdef _DEBUG -#include "objectdump.h" +#include "objectdump/objectdump.h" #endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 4496feb..dc18d20 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -1,89 +1,3 @@ -# MMF Phonon backend - -QT += phonon -TARGET = phonon_mmf -PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf - -# Uncomment the following line in order to use the CDrmPlayerUtility client -# API for audio playback, rather than CMdaAudioPlayerUtility. -#CONFIG += phonon_mmf_audio_drm - -phonon_mmf_audio_drm { - LIBS += -lDrmAudioPlayUtility - - # In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this - # folder, as opposed to the public, where it is placed in - # epoc32/include. - INCLUDEPATH *= /epoc32/include/osextensions - - DEFINES += QT_PHONON_MMF_AUDIO_DRM -} else { - LIBS += -lmediaclientaudio -} - -HEADERS += \ - $$PHONON_MMF_DIR/abstractplayer.h \ - $$PHONON_MMF_DIR/abstractmediaplayer.h \ - $$PHONON_MMF_DIR/audiooutput.h \ - $$PHONON_MMF_DIR/audioplayer.h \ - $$PHONON_MMF_DIR/backend.h \ - $$PHONON_MMF_DIR/defs.h \ - $$PHONON_MMF_DIR/dummyplayer.h \ - $$PHONON_MMF_DIR/mediaobject.h \ - $$PHONON_MMF_DIR/utils.h \ - $$PHONON_MMF_DIR/videooutput.h \ - $$PHONON_MMF_DIR/videooutputobserver.h \ - $$PHONON_MMF_DIR/videoplayer.h \ - $$PHONON_MMF_DIR/videowidget.h \ - $$PHONON_MMF_DIR/volumeobserver.h - -SOURCES += \ - $$PHONON_MMF_DIR/abstractplayer.cpp \ - $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ - $$PHONON_MMF_DIR/audiooutput.cpp \ - $$PHONON_MMF_DIR/audioplayer.cpp \ - $$PHONON_MMF_DIR/backend.cpp \ - $$PHONON_MMF_DIR/dummyplayer.cpp \ - $$PHONON_MMF_DIR/mediaobject.cpp \ - $$PHONON_MMF_DIR/utils.cpp \ - $$PHONON_MMF_DIR/videooutput.cpp \ - $$PHONON_MMF_DIR/videoplayer.cpp \ - $$PHONON_MMF_DIR/videowidget.cpp - -# This is not mmfphonon-specific, and should be factored out into a separate -# library (QtCore?) at a later date -debug { -HEADERS += \ - $$PHONON_MMF_DIR/objectdump.h \ - $$PHONON_MMF_DIR/objectdump_symbian.h \ - $$PHONON_MMF_DIR/objecttree.h - -SOURCES += \ - $$PHONON_MMF_DIR/objectdump.cpp \ - $$PHONON_MMF_DIR/objectdump_symbian.cpp \ - $$PHONON_MMF_DIR/objecttree.cpp - -} - -LIBS += -lmediaclientvideo # For CVideoPlayerUtility -LIBS += -lcone # For CCoeEnv -LIBS += -lws32 # For RWindow -LIBS += -lefsrv # For file server -LIBS += -lapgrfx -lapmime # For recognizer - -# This is needed for having the .qtplugin file properly created on Symbian. -QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend - -target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend -INSTALLS += target - -include(../../qpluginbase.pri) - -# We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon and -# the SDK has the header. -INCLUDEPATH *= /epoc32 - -# Temporary steal one of the reserved, until we know that this MMF plugin is -# turning into something at all. -symbian:TARGET.UID3=0x2001E627 +TEMPLATE = subdirs +SUBDIRS = objectdump plugin diff --git a/src/plugins/phonon/mmf/objectdump/objectdump.pro b/src/plugins/phonon/mmf/objectdump/objectdump.pro new file mode 100644 index 0000000..b9e2017 --- /dev/null +++ b/src/plugins/phonon/mmf/objectdump/objectdump.pro @@ -0,0 +1,28 @@ +TEMPLATE = lib +TARGET = objectdump +OBJECTDUMP_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf/objectdump + +CONFIG += dll + +DEFINES += OBJECTDUMP_LIBRARY + +HEADERS += \ + $$OBJECTDUMP_DIR/objectdump_global.h \ + $$OBJECTDUMP_DIR/objectdump.h \ + $$OBJECTDUMP_DIR/objecttree.h + +SOURCES += \ + $$OBJECTDUMP_DIR/objectdump.cpp \ + $$OBJECTDUMP_DIR/objecttree.cpp + +symbian { + HEADERS += $$OBJECTDUMP_DIR/objectdump_symbian.h + SOURCES += $$OBJECTDUMP_DIR/objectdump_symbian.cpp + + LIBS += -lcone + LIBS += -lws32 + + TARGET.CAPABILITY = all -tcb +} else { + SOURCES += $$OBJECTDUMP_DIR/objectdump_stub.cpp +} diff --git a/src/plugins/phonon/mmf/plugin/plugin.pro b/src/plugins/phonon/mmf/plugin/plugin.pro new file mode 100644 index 0000000..418d354 --- /dev/null +++ b/src/plugins/phonon/mmf/plugin/plugin.pro @@ -0,0 +1,79 @@ +# MMF Phonon backend + +QT += phonon +TARGET = phonon_mmf +PHONON_MMF_DIR = $$QT_SOURCE_TREE/src/3rdparty/phonon/mmf + +# Uncomment the following line in order to use the CDrmPlayerUtility client +# API for audio playback, rather than CMdaAudioPlayerUtility. +#CONFIG += phonon_mmf_audio_drm + +phonon_mmf_audio_drm { + LIBS += -lDrmAudioPlayUtility + + # In the internal 5th SDK, DrmAudioSamplePlayer.h is placed in this + # folder, as opposed to the public, where it is placed in + # epoc32/include. + INCLUDEPATH *= /epoc32/include/osextensions + + DEFINES += QT_PHONON_MMF_AUDIO_DRM +} else { + LIBS += -lmediaclientaudio +} + +HEADERS += \ + $$PHONON_MMF_DIR/abstractplayer.h \ + $$PHONON_MMF_DIR/abstractmediaplayer.h \ + $$PHONON_MMF_DIR/audiooutput.h \ + $$PHONON_MMF_DIR/audioplayer.h \ + $$PHONON_MMF_DIR/backend.h \ + $$PHONON_MMF_DIR/defs.h \ + $$PHONON_MMF_DIR/dummyplayer.h \ + $$PHONON_MMF_DIR/mediaobject.h \ + $$PHONON_MMF_DIR/utils.h \ + $$PHONON_MMF_DIR/videooutput.h \ + $$PHONON_MMF_DIR/videooutputobserver.h \ + $$PHONON_MMF_DIR/videoplayer.h \ + $$PHONON_MMF_DIR/videowidget.h \ + $$PHONON_MMF_DIR/volumeobserver.h + +SOURCES += \ + $$PHONON_MMF_DIR/abstractplayer.cpp \ + $$PHONON_MMF_DIR/abstractmediaplayer.cpp \ + $$PHONON_MMF_DIR/audiooutput.cpp \ + $$PHONON_MMF_DIR/audioplayer.cpp \ + $$PHONON_MMF_DIR/backend.cpp \ + $$PHONON_MMF_DIR/dummyplayer.cpp \ + $$PHONON_MMF_DIR/mediaobject.cpp \ + $$PHONON_MMF_DIR/utils.cpp \ + $$PHONON_MMF_DIR/videooutput.cpp \ + $$PHONON_MMF_DIR/videoplayer.cpp \ + $$PHONON_MMF_DIR/videowidget.cpp + +debug { + INCLUDEPATH += $$PHONON_MMF_DIR/objectdump + LIBS += -lobjectdump +} + +LIBS += -lmediaclientvideo # For CVideoPlayerUtility +LIBS += -lcone # For CCoeEnv +LIBS += -lws32 # For RWindow +LIBS += -lefsrv # For file server +LIBS += -lapgrfx -lapmime # For recognizer + +# This is needed for having the .qtplugin file properly created on Symbian. +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/phonon_backend + +target.path = $$[QT_INSTALL_PLUGINS]/phonon_backend +INSTALLS += target + +include(../../../qpluginbase.pri) + +# We need this to be able to resolve ambiguity for VideoPlayer.h. Phonon and +# the SDK has the header. +INCLUDEPATH *= /epoc32 + +# Temporary steal one of the reserved, until we know that this MMF plugin is +# turning into something at all. +symbian:TARGET.UID3=0x2001E627 + -- cgit v0.12