diff options
author | Alex <qt-info@nokia.com> | 2010-01-19 17:32:01 +1000 |
---|---|---|
committer | Alex <qt-info@nokia.com> | 2010-01-19 17:32:01 +1000 |
commit | 7101291f0f63e6fdd836ea4d0acfc178219a11c8 (patch) | |
tree | 1442e37d0f980d3e72725073daf7fe1ba6236da8 | |
parent | 421dbade074a0f5c035b81102408deb33485f1e2 (diff) |
add a bit more infrastructure to point out where we want to go
names of API elements are not final
-rw-r--r-- | examples/sfwipcservice/main.cpp | 7 | ||||
-rw-r--r-- | examples/sfwipcservice/sfwipcservice.pro | 2 | ||||
-rw-r--r-- | src/serviceframework/ipc/ipc.pri | 16 | ||||
-rw-r--r-- | src/serviceframework/ipc/ipcendpoint.cpp | 76 | ||||
-rw-r--r-- | src/serviceframework/ipc/ipcendpoint_p.h | 78 | ||||
-rw-r--r-- | src/serviceframework/ipc/objectendpoint.cpp | 59 | ||||
-rw-r--r-- | src/serviceframework/ipc/objectendpoint_p.h | 63 | ||||
-rw-r--r-- | src/serviceframework/ipc/qservicecontrol.cpp | 69 | ||||
-rw-r--r-- | src/serviceframework/ipc/qservicecontrol.h | 68 | ||||
-rw-r--r-- | src/serviceframework/ipc/qservicecontrol_p.cpp | 157 | ||||
-rw-r--r-- | src/serviceframework/ipc/qservicecontrol_p.h | 74 | ||||
-rw-r--r-- | src/serviceframework/ipc/qservicepackage.cpp | 125 | ||||
-rw-r--r-- | src/serviceframework/ipc/qservicepackage_p.h | 108 | ||||
-rw-r--r-- | src/serviceframework/qservicefilter.cpp | 2 |
14 files changed, 899 insertions, 5 deletions
diff --git a/examples/sfwipcservice/main.cpp b/examples/sfwipcservice/main.cpp index 2da6a02c7e..040388b727 100644 --- a/examples/sfwipcservice/main.cpp +++ b/examples/sfwipcservice/main.cpp @@ -1,5 +1,6 @@ #include <QApplication> #include <qservicetyperegister.h> +#include <qservicecontrol.h> #include <instancemanager_p.h> #include <QDebug> @@ -46,7 +47,11 @@ int main(int argc, char** argv) qWarning() << i.first << i.second << testService << uid; } - //return app.exec(); + + QServiceControl* control = new QServiceControl(); + control->publishServices("qt_sfw_example_ipc_ident"); + return app.exec(); + delete control; } #include "main.moc" diff --git a/examples/sfwipcservice/sfwipcservice.pro b/examples/sfwipcservice/sfwipcservice.pro index ac2ce6eb20..1614c12af3 100644 --- a/examples/sfwipcservice/sfwipcservice.pro +++ b/examples/sfwipcservice/sfwipcservice.pro @@ -5,7 +5,7 @@ INCLUDEPATH += ../../src/serviceframework/ipc include(../examples.pri) -QT += core +QT += core network # Input SOURCES += main.cpp diff --git a/src/serviceframework/ipc/ipc.pri b/src/serviceframework/ipc/ipc.pri index a53656f9b2..1c380ceb1a 100644 --- a/src/serviceframework/ipc/ipc.pri +++ b/src/serviceframework/ipc/ipc.pri @@ -5,7 +5,12 @@ PRIVATE_HEADERS += \ ipc/qsignalintercepter_p.h \ ipc/qmetaobjectbuilder_p.h \ ipc/instancemanager_p.h \ - ipc/qservicetyperegister.h + ipc/qservicetyperegister.h \ + ipc/qservicecontrol.h \ + ipc/qservicecontrol_p.h \ + ipc/qservicepackage_p.h \ + ipc/objectendpoint_p.h \ + ipc/ipcendpoint_p.h SOURCES += \ @@ -13,4 +18,11 @@ SOURCES += \ ipc/qsignalintercepter.cpp \ ipc/qmetaobjectbuilder.cpp \ ipc/qservicetyperegister.cpp \ - ipc/instancemanager.cpp + ipc/instancemanager.cpp \ + ipc/qservicecontrol.cpp \ + ipc/qservicepackage.cpp \ + ipc/qservicecontrol_p.cpp \ + ipc/objectendpoint.cpp \ + ipc/ipcendpoint.cpp + +!symbian:QT+=network #for QLocalServer diff --git a/src/serviceframework/ipc/ipcendpoint.cpp b/src/serviceframework/ipc/ipcendpoint.cpp new file mode 100644 index 0000000000..62d8eb54fb --- /dev/null +++ b/src/serviceframework/ipc/ipcendpoint.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "ipcendpoint_p.h" + +QTM_BEGIN_NAMESPACE +/*! + QServiceIpcEndPoint +*/ +QServiceIpcEndPoint::QServiceIpcEndPoint(QObject* parent) + : QObject( parent ) +{ +} + +QServiceIpcEndPoint::~QServiceIpcEndPoint() +{ +} + +bool QServiceIpcEndPoint::packageAvailable() const +{ + return !incoming.isEmpty(); +} + +QServicePackage QServiceIpcEndPoint::readPackage() +{ + if (!incoming.isEmpty()) + return incoming.dequeue(); + return QServicePackage(); +} + +void QServiceIpcEndPoint::writePackage(QServicePackage newPackage) +{ + flushPackage(newPackage); + +} + +#include "moc_ipcendpoint_p.cpp" +QTM_END_NAMESPACE diff --git a/src/serviceframework/ipc/ipcendpoint_p.h b/src/serviceframework/ipc/ipcendpoint_p.h new file mode 100644 index 0000000000..b647a452da --- /dev/null +++ b/src/serviceframework/ipc/ipcendpoint_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef Q_SERVICECOMM_P_H +#define Q_SERVICECOMM_P_H + +#include "qmobilityglobal.h" +#include <QObject> +#include <QQueue> + +#include "qservicepackage_p.h" + +QTM_BEGIN_NAMESPACE + +class Q_AUTOTEST_EXPORT QServiceIpcEndPoint : public QObject +{ + Q_OBJECT +public: + QServiceIpcEndPoint(QObject* object = 0); + virtual ~QServiceIpcEndPoint(); + + bool packageAvailable() const; + QServicePackage readPackage(); + + void writePackage(QServicePackage newPackage); + +Q_SIGNALS: + void readyRead(); + void disconnected(); + +protected: + virtual void flushPackage(const QServicePackage& out) = 0; + + QQueue<QServicePackage> incoming; +}; + + +QTM_END_NAMESPACE + +#endif //Q_SERVICECOMM_P_H diff --git a/src/serviceframework/ipc/objectendpoint.cpp b/src/serviceframework/ipc/objectendpoint.cpp new file mode 100644 index 0000000000..9782ad5507 --- /dev/null +++ b/src/serviceframework/ipc/objectendpoint.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "objectendpoint_p.h" + +QTM_BEGIN_NAMESPACE + +ObjectEndPoint::ObjectEndPoint(QServiceIpcEndPoint* comm, QObject* parent) + : QObject(parent), dispatch(comm) +{ + Q_ASSERT(dispatch); + dispatch->setParent(this); +} + +ObjectEndPoint::~ObjectEndPoint() +{ +} + +#include "moc_objectendpoint_p.cpp" + +QTM_END_NAMESPACE diff --git a/src/serviceframework/ipc/objectendpoint_p.h b/src/serviceframework/ipc/objectendpoint_p.h new file mode 100644 index 0000000000..181b92ebc6 --- /dev/null +++ b/src/serviceframework/ipc/objectendpoint_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef OBJECT_ENDPOINT_H +#define OBJECT_ENDPOINT_H + +#include "qmobilityglobal.h" +#include "ipcendpoint_p.h" + +QTM_BEGIN_NAMESPACE + +class ObjectEndPoint : public QObject +{ + Q_OBJECT +public: + ObjectEndPoint(QServiceIpcEndPoint* comm, QObject* parent = 0); + ~ObjectEndPoint(); + +private: + QServiceIpcEndPoint* dispatch; +}; + +QTM_END_NAMESPACE + +#endif //OBJECT_ENDPOINT_H diff --git a/src/serviceframework/ipc/qservicecontrol.cpp b/src/serviceframework/ipc/qservicecontrol.cpp new file mode 100644 index 0000000000..34a3cd78b9 --- /dev/null +++ b/src/serviceframework/ipc/qservicecontrol.cpp @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qservicecontrol.h" +#include "qservicecontrol_p.h" + +QTM_BEGIN_NAMESPACE + + +/*! + QServiceControl +*/ +QServiceControl::QServiceControl(QObject* parent) + : QObject(parent) +{ + d = new QServiceControlPrivate(this); +} + +QServiceControl::~QServiceControl() +{ +} + +void QServiceControl::publishServices( const QString& ident) +{ + d->publishServices(ident); +} + + +#include "moc_qservicecontrol.cpp" + +QTM_END_NAMESPACE diff --git a/src/serviceframework/ipc/qservicecontrol.h b/src/serviceframework/ipc/qservicecontrol.h new file mode 100644 index 0000000000..2a2a255df2 --- /dev/null +++ b/src/serviceframework/ipc/qservicecontrol.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSERVICECONTROL_H +#define QSERVICECONTROL_H + +#include "qmobilityglobal.h" +#include <QObject> +#include <QQueue> + + +QTM_BEGIN_NAMESPACE + + +class QServiceControlPrivate; +class Q_SERVICEFW_EXPORT QServiceControl : public QObject +{ + Q_OBJECT +public: + QServiceControl(QObject* parent = 0); + ~QServiceControl(); + + void publishServices(const QString& ident ); + +private: + QServiceControlPrivate* d; +}; + +QTM_END_NAMESPACE +#endif //QSERVICECONTROL_H diff --git a/src/serviceframework/ipc/qservicecontrol_p.cpp b/src/serviceframework/ipc/qservicecontrol_p.cpp new file mode 100644 index 0000000000..fa7a26303c --- /dev/null +++ b/src/serviceframework/ipc/qservicecontrol_p.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qservicecontrol_p.h" +#include "ipcendpoint_p.h" +#include "objectendpoint_p.h" + +#ifdef Q_OS_SYMBIAN +#else +#include <QLocalServer> +#include <QLocalSocket> +#include <QDataStream> +#include <QTimer> +#endif + +QTM_BEGIN_NAMESPACE + +//IPC is based on QLocalSocket + +#ifdef Q_OS_SYMBIAN +#else + +class LocalSocketEndPoint : public QServiceIpcEndPoint +{ + Q_OBJECT +public: + LocalSocketEndPoint(QLocalSocket* s, QObject* parent = 0) + : QServiceIpcEndPoint(parent), socket(s) + { + Q_ASSERT(socket); + socket->setParent(this); + connect(s, SIGNAL(readyRead()), this, SLOT(readIncoming())); + + if (socket->bytesAvailable()) + QTimer::singleShot(0, this, SLOT(readIncoming())); + } + +protected: + void flushPackage(const QServicePackage& package) + { + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + out.setVersion(QDataStream::Qt_4_6); + out << package; + socket->write(block); + } + +protected slots: + void readIncoming() + { + QDataStream in(socket); + in.setVersion(QDataStream::Qt_4_6); + + while(socket->bytesAvailable()) { + QServicePackage package; + in >> package; + incoming.enqueue(package); + } + + emit readyRead(); + } + +private: + QLocalSocket* socket; +}; + +#endif + +QServiceControlPrivate::QServiceControlPrivate(QObject* parent) + : QObject(parent) +{ +} + +void QServiceControlPrivate::publishServices( const QString& ident) +{ + //for now we just have LocalSocket + createServiceEndPoint(ident) ; +} + +void QServiceControlPrivate::processIncoming() +{ +#ifdef Q_OS_SYMBIAN +#else + //for now we have QLocalSocket only + qDebug() << "Processing incoming connect"; + if (localServer->hasPendingConnections()) { + QLocalSocket* s = localServer->nextPendingConnection(); + LocalSocketEndPoint* endPoint = new LocalSocketEndPoint(s); + ObjectEndPoint* endpoint = new ObjectEndPoint(endPoint, this); + pendingConnections.append(endpoint); + } +#endif +} + +bool QServiceControlPrivate::createServiceEndPoint(const QString& ident) +{ + //for now we have QLocalSocket only + //other IPC mechanisms such as dbus may have to publish the + //meta object definition for all registered service types +#ifdef Q_OS_SYMBIAN +#else + QLocalServer::removeServer(ident); + qDebug() << "Start listening for incoming connections"; + QLocalServer* server = new QLocalServer(this); + if ( !server->listen(ident) ) { + qWarning() << "Cannot create COM endpoint"; + return false; + } + connect(server, SIGNAL(newConnection()), this, SLOT(processIncoming())); + if (server->hasPendingConnections()) + QTimer::singleShot(0, this, SLOT(processIncoming())); + + return true; +#endif +} + +#include "moc_qservicecontrol_p.cpp" +#include "qservicecontrol_p.moc" +QTM_END_NAMESPACE diff --git a/src/serviceframework/ipc/qservicecontrol_p.h b/src/serviceframework/ipc/qservicecontrol_p.h new file mode 100644 index 0000000000..49ea389680 --- /dev/null +++ b/src/serviceframework/ipc/qservicecontrol_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSERVICECONTROL_P_H +#define QSERVICECONTROL_P_H + +#include "qservicecontrol.h" +#include "instancemanager_p.h" +#include <QLocalServer> + +QTM_BEGIN_NAMESPACE + +class ObjectEndPoint; +class QServiceControlPrivate: public QObject +{ + Q_OBJECT +public: + QServiceControlPrivate(QObject* parent); + void publishServices(const QString& ident ); + +public slots: + void processIncoming(); +private: + bool createServiceEndPoint(const QString& ident); +#ifdef Q_OS_SYMBIAN +#else + QLocalServer* localServer; +#endif + QList<ObjectEndPoint*> pendingConnections; + +}; + + +QTM_END_NAMESPACE + +#endif diff --git a/src/serviceframework/ipc/qservicepackage.cpp b/src/serviceframework/ipc/qservicepackage.cpp new file mode 100644 index 0000000000..ab297939f0 --- /dev/null +++ b/src/serviceframework/ipc/qservicepackage.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qservicepackage_p.h" +#include <QDebug> + +QTM_BEGIN_NAMESPACE + +QServicePackage::QServicePackage() + : d(0) +{ + +} + +QServicePackage::QServicePackage(const QServicePackage& other) + : d(other.d) +{ +} + +QServicePackage& QServicePackage::operator=(const QServicePackage& other) +{ + d = other.d; + return *this; +} + +QServicePackage::~QServicePackage() +{ +} + +bool QServicePackage::isValid() const +{ + return d; +} + +#ifndef QT_NO_DATASTREAM +QDataStream &operator<<(QDataStream &out, const QServicePackage& package) +{ + const quint32 magicNumber = 0x78AFAFB; + out.setVersion(QDataStream::Qt_4_6); + out << magicNumber; + + const qint8 valid = package.d ? 1 : 0; + out << (qint8) valid; + if (valid) { + out << (qint8) package.d->type; + } + + return out; +} + +QDataStream &operator>>(QDataStream &in, QServicePackage& package) +{ + const quint32 magicNumber = 0x78AFAFB; + in.setVersion(QDataStream::Qt_4_6); + + quint32 storedMagicNumber; + in >> storedMagicNumber; + if (storedMagicNumber != magicNumber) { + qWarning() << "Datastream doesn't provide serialized QServiceFilter"; + return in; + } + + qint8 valid; + in >> valid; + if (valid) { + if (!package.d) { + QServicePackagePrivate* priv = new QServicePackagePrivate(); + package.d = priv; + } else { + package.d.detach(); + package.d->clean(); + } + qint8 type; + in >> type; + package.d->type = (QServicePackage::Type) type; + } else { + if (package.d) + package.d.reset(); + } + + return in; +} +#endif + + + +QTM_END_NAMESPACE diff --git a/src/serviceframework/ipc/qservicepackage_p.h b/src/serviceframework/ipc/qservicepackage_p.h new file mode 100644 index 0000000000..2f71c54450 --- /dev/null +++ b/src/serviceframework/ipc/qservicepackage_p.h @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Mobility Components. +** +** $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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSERVICE_PACKAGE_H +#define QSERVICE_PACKAGE_H + +#include "qmobilityglobal.h" +#include <QExplicitlySharedDataPointer> +#include <QSharedData> + +QT_BEGIN_NAMESPACE +class QDataStream; +QT_END_NAMESPACE + +QTM_BEGIN_NAMESPACE + +class QServicePackagePrivate; +class Q_AUTOTEST_EXPORT QServicePackage +{ +public: + QServicePackage(); + QServicePackage(const QServicePackage& other); + QServicePackage& operator=(const QServicePackage& other); + ~QServicePackage(); + + enum Type { + MetaObjectRequest = 0, + SignalEmission, + ObjectCreation, + MethodCall + }; + + bool isValid() const; + +private: + QExplicitlySharedDataPointer<QServicePackagePrivate> d; + +#ifndef QT_NO_DATASTREAM + friend QDataStream &operator<<(QDataStream &, const QServicePackage&); + friend QDataStream &operator>>(QDataStream &, QServicePackage&); +#endif +}; + +#ifndef QT_NO_DATASTREAM +QDataStream &operator<<(QDataStream &, const QServicePackage&); +QDataStream &operator>>(QDataStream &, QServicePackage&); +#endif + + +class QServicePackagePrivate : public QSharedData +{ +public: + QServicePackagePrivate() : expectResponse(false) + { + clean(); + } + QServicePackage::Type type; + + bool expectResponse; //this package expects a resonse + + virtual void clean() + { + type = QServicePackage::MetaObjectRequest; + expectResponse = false; + } +}; + +QTM_END_NAMESPACE + +#endif diff --git a/src/serviceframework/qservicefilter.cpp b/src/serviceframework/qservicefilter.cpp index 6044e15c50..7d3c5bf228 100644 --- a/src/serviceframework/qservicefilter.cpp +++ b/src/serviceframework/qservicefilter.cpp @@ -481,7 +481,7 @@ QDataStream &operator>>(QDataStream &in, QServiceFilter &sf) quint32 storedMagicNumber; in >> storedMagicNumber; if (storedMagicNumber != magicNumber) { - qWarning() << "Datastream doesn't provide searialized QServiceFilter"; + qWarning() << "Datastream doesn't provide serialized QServiceFilter"; return in; } |