diff options
-rw-r--r-- | TODO | 7 | ||||
-rw-r--r-- | src/location/landmarks/qlandmarkmanagerenginefactory.h | 2 | ||||
-rw-r--r-- | src/location/maps/qgeoserviceproviderfactory.h | 2 | ||||
-rw-r--r-- | src/location/qgeoareamonitor.h | 10 | ||||
-rw-r--r-- | src/location/qgeopositioninfosourcefactory.h | 2 | ||||
-rw-r--r-- | src/location/qlatin1constant.h | 163 | ||||
-rw-r--r-- | src/location/qlocationutils_p.h | 8 | ||||
-rw-r--r-- | src/location/qmobilityglobal.h | 67 | ||||
-rw-r--r-- | src/location/qmobilitypluginsearch.h | 172 | ||||
-rw-r--r-- | sync.profile | 2 |
10 files changed, 418 insertions, 17 deletions
@@ -0,0 +1,7 @@ +The following tasks need to be done once backwards compatibility +towards Mobilty's QtLocation is somewhat less of an issue. + +- Remove qmobilityglobal.h +- Remove qlatin1constant.h (possible condidate for Qt) +- Remove qmobilitypluginsearch.h (convert to QFactoryLoader) +- Remove any occurance of QTM_* defines and associated QtMobility namespace diff --git a/src/location/landmarks/qlandmarkmanagerenginefactory.h b/src/location/landmarks/qlandmarkmanagerenginefactory.h index e5419a9b..d05ff292 100644 --- a/src/location/landmarks/qlandmarkmanagerenginefactory.h +++ b/src/location/landmarks/qlandmarkmanagerenginefactory.h @@ -64,7 +64,7 @@ QTM_END_NAMESPACE QT_BEGIN_NAMESPACE #define QT_LANDMARKS_BACKEND_INTERFACE "com.nokia.qt.mobility.landmarks.enginefactory/1.0" -Q_DECLARE_INTERFACE(QtMobility::QLandmarkManagerEngineFactory, QT_LANDMARKS_BACKEND_INTERFACE); +Q_DECLARE_INTERFACE(QLandmarkManagerEngineFactory, QT_LANDMARKS_BACKEND_INTERFACE); QT_END_NAMESPACE #endif diff --git a/src/location/maps/qgeoserviceproviderfactory.h b/src/location/maps/qgeoserviceproviderfactory.h index acaadb6d..7614edba 100644 --- a/src/location/maps/qgeoserviceproviderfactory.h +++ b/src/location/maps/qgeoserviceproviderfactory.h @@ -74,7 +74,7 @@ QTM_END_NAMESPACE QT_BEGIN_NAMESPACE #define QT_GEOSERVICE_BACKEND_INTERFACE "com.nokia.qt.mobility.geoservice.serviceproviderfactory/1.0" -Q_DECLARE_INTERFACE(QtMobility::QGeoServiceProviderFactory, QT_GEOSERVICE_BACKEND_INTERFACE); +Q_DECLARE_INTERFACE(QGeoServiceProviderFactory, QT_GEOSERVICE_BACKEND_INTERFACE); QT_END_NAMESPACE #endif diff --git a/src/location/qgeoareamonitor.h b/src/location/qgeoareamonitor.h index 54737f68..ee478458 100644 --- a/src/location/qgeoareamonitor.h +++ b/src/location/qgeoareamonitor.h @@ -48,14 +48,7 @@ QT_BEGIN_HEADER -#ifdef Q_QDOC -//normally we would use macro only but this causes some other compilation issues QTM_BEGIN_NAMESPACE -#else -namespace QtMobility -{ -#endif - class QGeoPositionInfo; class QGeoAreaMonitorPrivate; @@ -86,7 +79,8 @@ private: QGeoAreaMonitorPrivate *d; }; -} + +QTM_END_NAMESPACE QT_END_HEADER diff --git a/src/location/qgeopositioninfosourcefactory.h b/src/location/qgeopositioninfosourcefactory.h index 5940828f..4a73247e 100644 --- a/src/location/qgeopositioninfosourcefactory.h +++ b/src/location/qgeopositioninfosourcefactory.h @@ -66,7 +66,7 @@ QTM_END_NAMESPACE QT_BEGIN_NAMESPACE #define QT_POSITION_SOURCE_INTERFACE "com.nokia.qt.mobility.position.sourcefactory/1.0" -Q_DECLARE_INTERFACE(QtMobility::QGeoPositionInfoSourceFactory, QT_POSITION_SOURCE_INTERFACE); +Q_DECLARE_INTERFACE(QGeoPositionInfoSourceFactory, QT_POSITION_SOURCE_INTERFACE); QT_END_NAMESPACE #endif // QGEOPOSITIONINFOSOURCEFACTORY_H diff --git a/src/location/qlatin1constant.h b/src/location/qlatin1constant.h new file mode 100644 index 00000000..46210288 --- /dev/null +++ b/src/location/qlatin1constant.h @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** 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 QLATIN1CONSTANT_H +#define QLATIN1CONSTANT_H + +#include <QString> +#include <QVariant> + +QTM_BEGIN_NAMESPACE + +/* + * QLatin1Constant + * + * The idea of the QLatin1Constant is to provide a POD-esque container + * for constant strings which are defined in various places + * (e.g., detail leaf class definition names, field keys, constant field values, etc). + * We would ideally like these to be stored in the .rodata section to allow + * sharing / minimise footprint. + * + * Given that the declare/define macros are const anyway, we changed the + * member to a char array from a const char array, in order to squash + * the compiler warning regarding uninitialised const value without + * initialiser list in default ctor (POD requires default ctor). + */ + +//QTM_SYNC_HEADER_EXPORT QLatin1Constant +template <int N> struct QLatin1Constant +{ + char chars[N]; + + bool operator ==(const QLatin1Constant& other) const {return (chars == other.chars) || (qstrcmp(chars, other.chars) == 0);} + bool operator !=(const QLatin1Constant& other) const {return !operator==(other);} + + inline const char * latin1() const {return chars;} + + operator QLatin1String() const {return QLatin1String(chars);} + operator QString() const {return QString::fromLatin1(chars, N-1);} + operator QVariant() const {return QVariant(operator QString());} +}; + +/* Hash - this comes from qhash.cpp >.> */ +template<int N> uint qHash(const QLatin1Constant<N>& a) +{ + uint h = 0; + uint g; + int n = N - 1; + const register uchar*p = (const uchar*)a.chars; + + while (n--) { + h = (h << 4) + *p++; + if ((g = (h & 0xf0000000)) != 0) + h ^= g >> 23; + h &= ~g; + } + return h; +} + +/* Operators for QLatin1Constant */ +template<int N, int M> bool operator==(const QLatin1Constant<N>&, const QLatin1Constant<M>&) +{ + // For N != M, this is always false + // For N == M, the member function gets called + return false; +} +template<int N, int M> bool operator!=(const QLatin1Constant<N>&, const QLatin1Constant<M>&) +{ + // If N != M, this is always true + // For N == M, the member function again gets called + return true; +} + +template<int N, int M> bool operator <(const QLatin1Constant<N>& a, const QLatin1Constant<M>& b) +{ + return qstrcmp(a.chars, b.chars) < 0; +} + +/* Operators for QLatin1String */ +template<int N> bool operator==(const QLatin1Constant<N>& a, const QLatin1String& b) +{ + return (a.chars == b.latin1()) || (qstrcmp(a.chars, b.latin1()) == 0); +} + +template<int N> bool operator==(const QLatin1String& b, const QLatin1Constant<N>& a) +{ + return (a.chars == b.latin1()) || (qstrcmp(a.chars, b.latin1()) == 0); +} + +template<int N> bool operator!=(const QLatin1Constant<N>& a, const QLatin1String& b) +{ + return (a.chars != b.latin1()) && (qstrcmp(a.chars, b.latin1()) != 0); +} + +template<int N> bool operator!=(const QLatin1String& b, const QLatin1Constant<N>& a) +{ + return (a.chars != b.latin1()) && (qstrcmp(a.chars, b.latin1()) != 0); +} + +/* Operators for QString */ +template<int N> bool operator==(const QLatin1Constant<N>& a, const QString& b) +{ + return b == QLatin1String(a.chars); +} + +template<int N> bool operator==(const QString& b, const QLatin1Constant<N>& a) +{ + return b == QLatin1String(a.chars); +} + +template<int N> bool operator!=(const QLatin1Constant<N>& a, const QString& b) +{ + return b != QLatin1String(a.chars); +} + +template<int N> bool operator!=(const QString& b, const QLatin1Constant<N>& a) +{ + return b != QLatin1String(a.chars); +} + +#define Q_DECLARE_LATIN1_CONSTANT(varname, str) static const QLatin1Constant<sizeof(str)> varname +#define Q_DEFINE_LATIN1_CONSTANT(varname, str) const QLatin1Constant<sizeof(str)> varname = {str} + +QTM_END_NAMESPACE + +#endif diff --git a/src/location/qlocationutils_p.h b/src/location/qlocationutils_p.h index 2c39aba0..16d6dd8c 100644 --- a/src/location/qlocationutils_p.h +++ b/src/location/qlocationutils_p.h @@ -81,23 +81,23 @@ public: - RMC reports date with a two-digit year so in this case the year is assumed to be after the year 2000. */ - QM_AUTOTEST_EXPORT static bool getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info, bool *hasFix = 0); + Q_AUTOTEST_EXPORT static bool getPosInfoFromNmea(const char *data, int size, QGeoPositionInfo *info, bool *hasFix = 0); /* Returns true if the given NMEA sentence has a valid checksum. */ - QM_AUTOTEST_EXPORT static bool hasValidNmeaChecksum(const char *data, int size); + Q_AUTOTEST_EXPORT static bool hasValidNmeaChecksum(const char *data, int size); /* Returns time from a string in hhmmss or hhmmss.z+ format. */ - QM_AUTOTEST_EXPORT static bool getNmeaTime(const QByteArray &bytes, QTime *time); + Q_AUTOTEST_EXPORT static bool getNmeaTime(const QByteArray &bytes, QTime *time); /* Accepts e.g. ("2734.7964", 'S', "15306.0124", 'E') and returns the lat-long values. Fails if lat or long fail isValidLat() or isValidLong(). */ - QM_AUTOTEST_EXPORT static bool getNmeaLatLong(const QByteArray &latString, char latDirection, const QByteArray &lngString, char lngDirection, double *lat, double *lon); + Q_AUTOTEST_EXPORT static bool getNmeaLatLong(const QByteArray &latString, char latDirection, const QByteArray &lngString, char lngDirection, double *lat, double *lon); }; QTM_END_NAMESPACE diff --git a/src/location/qmobilityglobal.h b/src/location/qmobilityglobal.h new file mode 100644 index 00000000..04d65d41 --- /dev/null +++ b/src/location/qmobilityglobal.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** 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 QMOBILITYGLOBAL_H +#define QMOBILITYGLOBAL_H + +#include <QtCore/qglobal.h> + +// The namespace is hardcoded as moc has issues resolving +// macros which would be a prerequisite for a dynmamic namespace +//#define QTM_NAMESPACE QtMobility +//#define QTM_NAMESPACE + +#ifdef QTM_NAMESPACE +# define QTM_PREPEND_NAMESPACE(name) ::QTM_NAMESPACE::name +# define QTM_BEGIN_NAMESPACE namespace QTM_NAMESPACE { +# define QTM_END_NAMESPACE } +# define QTM_USE_NAMESPACE using namespace QTM_NAMESPACE; +#else +# define QTM_PREPEND_NAMESPACE(name) ::name +# define QTM_BEGIN_NAMESPACE +# define QTM_END_NAMESPACE +# define QTM_USE_NAMESPACE +#endif + +//in case Qt is in namespace +QT_USE_NAMESPACE + +#endif // QMOBILITYGLOBAL_H + diff --git a/src/location/qmobilitypluginsearch.h b/src/location/qmobilitypluginsearch.h new file mode 100644 index 00000000..05dca3ca --- /dev/null +++ b/src/location/qmobilitypluginsearch.h @@ -0,0 +1,172 @@ +/**************************************************************************** +** +** 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 QMOBILITYPLUGINSEARCH_H +#define QMOBILITYPLUGINSEARCH_H + +#include <QCoreApplication> +#include <QStringList> +#include <QDir> +#include <QDebug> + +#if defined(Q_OS_SYMBIAN) +# include <f32file.h> +#endif + +QTM_BEGIN_NAMESPACE + +#if defined(Q_OS_SYMBIAN) +static inline bool qSymbian_CheckDir(const QDir& dir, RFs& rfs) +{ + bool pathFound = false; + // In Symbian, going cdUp() in a c:/private/<uid3>/ will result in *platsec* error at fileserver (requires AllFiles capability) + // Also, trying to cd() to a nonexistent directory causes *platsec* error. This does not cause functional harm, but should + // nevertheless be changed to use native Symbian methods to avoid unnecessary platsec warnings (as per qpluginloader.cpp). + // Use native Symbian code to check for directory existence, because checking + // for files from under non-existent protected dir like E:/private/<uid> using + // QDir::exists causes platform security violations on most apps. + QString nativePath = QDir::toNativeSeparators(dir.absolutePath()); + TPtrC ptr = TPtrC16(static_cast<const TUint16*>(nativePath.utf16()), nativePath.length()); + TUint attributes; + TInt err = rfs.Att(ptr, attributes); + if (err == KErrNone) { + // yes, the directory exists. + pathFound = true; + } + return pathFound; +} +#define CHECKDIR(dir) qSymbian_CheckDir(dir, rfs) +#else +#define CHECKDIR(dir) (dir).exists() +#endif + +inline QStringList mobilityPlugins(const QString& plugintype) +{ +#if !defined QT_NO_DEBUG + const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0; +#endif + + QStringList paths = QCoreApplication::libraryPaths(); +/*#ifdef QTM_PLUGIN_PATH + paths << QLatin1String(QTM_PLUGIN_PATH); +#endif*/ +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Plugin paths:" << paths; +#endif + +#if defined(Q_OS_SYMBIAN) + RFs rfs; + qt_symbian_throwIfError(rfs.Connect()); +#endif + + // Temp variable to avoid multiple identical paths + // (we don't convert the list to set first, because that loses the order) + QSet<QString> processed; + + /* The list of discovered plugins */ + QStringList plugins; + + /* Enumerate our plugin paths */ + for (int i=0; i < paths.count(); i++) { + if (processed.contains(paths.at(i))) + continue; + processed.insert(paths.at(i)); + QDir pluginsDir(paths.at(i)); + if (!CHECKDIR(pluginsDir)) + continue; + +#if defined(Q_OS_WIN) + if (pluginsDir.dirName().toLower() == QLatin1String("debug") || pluginsDir.dirName().toLower() == QLatin1String("release")) + pluginsDir.cdUp(); +#elif defined(Q_OS_MAC) + if (pluginsDir.dirName() == QLatin1String("MacOS")) { + pluginsDir.cdUp(); + pluginsDir.cdUp(); + pluginsDir.cdUp(); + } +#endif + + QString subdir(QLatin1String("plugins/")); + subdir += plugintype; + if (pluginsDir.path().endsWith(QLatin1String("/plugins")) + || pluginsDir.path().endsWith(QLatin1String("/plugins/"))) + subdir = plugintype; + + if (CHECKDIR(QDir(pluginsDir.filePath(subdir)))) { + pluginsDir.cd(subdir); + QStringList files = pluginsDir.entryList(QDir::Files); + +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Looking for " << plugintype << " plugins in" << pluginsDir.path() << files; +#endif + + for (int j=0; j < files.count(); j++) { + plugins << pluginsDir.absoluteFilePath(files.at(j)); + } + } + } + + /* Add application path + plugintype */ + QDir appldir(QCoreApplication::applicationDirPath()); + if(appldir.cd(plugintype)){ + if (!processed.contains(appldir.absolutePath())){ + processed.insert(appldir.absolutePath()); + QStringList files = appldir.entryList(QDir::Files); +#if !defined QT_NO_DEBUG + if (showDebug) + qDebug() << "Looking for " << plugintype << " plugins in" << appldir.path() << files; +#endif + for (int j=0; j < files.count(); j++) { + plugins << appldir.absoluteFilePath(files.at(j)); + } + } + } + +#if defined(Q_OS_SYMBIAN) + rfs.Close(); +#endif + return plugins; +} + +QTM_END_NAMESPACE + +#endif diff --git a/sync.profile b/sync.profile index 79111dcd..1dbdaeda 100644 --- a/sync.profile +++ b/sync.profile @@ -8,7 +8,6 @@ %mastercontent = ( "gui" => "#include <QtGui/QtGui>\n", "network" => "#include <QtNetwork/QtNetwork>\n", - "sql" => "#include <QtSql/QtSql>\n", ); %modulepris = ( "QtLocation" => "$basedir/modules/qt_location.pri", @@ -23,7 +22,6 @@ "QtLocation" => { "QtGui" => "0c637cb07ba3c9b353e7e483a209537485cc4e2a", "QtNetwork" => "0c637cb07ba3c9b353e7e483a209537485cc4e2a", - "QtSql" => "0c637cb07ba3c9b353e7e483a209537485cc4e2a", "QtCore" => "0c637cb07ba3c9b353e7e483a209537485cc4e2a", }, ); |