Ok, I read some more about writing plugins and source code of nokia plugin. So far I think I understand what must be done, but it doesn't work. Here's what I have:
I complied and installed qtmobility with ./configure -prefix /mybin/qtmobility12_custom_forqt474 -qmake-exec /mybin/qt474_custom/bin/qmake (...)
Currently I try to make it work on desktop, so I only use qt from above version, located in /mybin/qt474_custom . I'll worry about other versions when at least this one works.
# OsmPlugin.pro
QT += core gui network
TARGET = $$qtLibraryTarget(qtgeoservices_mlosm)
TEMPLATE = lib
CONFIG += plugin mobility
MOBILITY = location
PLUGIN_TYPE=geoservices
DESTDIR = $$[QT_INSTALL_PLUGINS]/geoservices
SOURCES += \
osmtilereply.cpp \
osmmapserviceproviderfactory.cpp \
osmmappingmanagerengine.cpp
HEADERS += \
osmtilereply.h \
osmmapserviceproviderfactory.h \
osmmappingmanagerengine.h
# To use my suplied version of qtmobility for desktop
INCLUDEPATH +=/mybin/qtmobility12_custom_forqt474/include/QtLocation \
/mybin/qtmobility12_custom_forqt474/include/QtMobility
LIBS += -L/mybin/qtmobility12_custom_forqt474/lib -lQtLocation
symbian {
# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
load(data_caging_paths)
MMP_RULES += EXPORTUNFROZEN
TARGET.UID3 = 0xE7FBA200
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
pluginDeploy.sources = OsmPlugin.dll
pluginDeploy.path = $$QT_PLUGINS_BASE_DIR/OsmPlugin
DEPLOYMENT += pluginDeploy
}
unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}
OTHER_FILES += \
qtc_packaging/debian_fremantle/rules \
qtc_packaging/debian_fremantle/README \
qtc_packaging/debian_fremantle/copyright \
qtc_packaging/debian_fremantle/control \
qtc_packaging/debian_fremantle/compat \
qtc_packaging/debian_fremantle/changelog
# OsmPlugin.pro
QT += core gui network
TARGET = $$qtLibraryTarget(qtgeoservices_mlosm)
TEMPLATE = lib
CONFIG += plugin mobility
MOBILITY = location
PLUGIN_TYPE=geoservices
DESTDIR = $$[QT_INSTALL_PLUGINS]/geoservices
SOURCES += \
osmtilereply.cpp \
osmmapserviceproviderfactory.cpp \
osmmappingmanagerengine.cpp
HEADERS += \
osmtilereply.h \
osmmapserviceproviderfactory.h \
osmmappingmanagerengine.h
# To use my suplied version of qtmobility for desktop
INCLUDEPATH +=/mybin/qtmobility12_custom_forqt474/include/QtLocation \
/mybin/qtmobility12_custom_forqt474/include/QtMobility
LIBS += -L/mybin/qtmobility12_custom_forqt474/lib -lQtLocation
symbian {
# Load predefined include paths (e.g. QT_PLUGINS_BASE_DIR) to be used in the pro-files
load(data_caging_paths)
MMP_RULES += EXPORTUNFROZEN
TARGET.UID3 = 0xE7FBA200
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
pluginDeploy.sources = OsmPlugin.dll
pluginDeploy.path = $$QT_PLUGINS_BASE_DIR/OsmPlugin
DEPLOYMENT += pluginDeploy
}
unix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}
OTHER_FILES += \
qtc_packaging/debian_fremantle/rules \
qtc_packaging/debian_fremantle/README \
qtc_packaging/debian_fremantle/copyright \
qtc_packaging/debian_fremantle/control \
qtc_packaging/debian_fremantle/compat \
qtc_packaging/debian_fremantle/changelog
To copy to clipboard, switch view to plain text mode
#header for my plugin class
#ifndef OSMMAPSERVICEPROVIDERFACTORY_H
#define OSMMAPSERVICEPROVIDERFACTORY_H
#include <QGeoServiceProviderFactory>
#include "osmmappingmanagerengine.h"
using namespace QtMobility;
class OsmMapServiceProviderFactory
: public QObject,
public QGeoServiceProviderFactory
{
//QObject is needed for Q_EXPORT_PLUGIN2 - it works only with QObject derived classes,
//and QGeoServiceProviderFactory is not one of them.
Q_OBJECT
public:
explicit OsmMapServiceProviderFactory();
QString providerName
() const {return "mlosm";
} int providerVersion() const {return 1; }
QGeoMappingManagerEngine* createMappingManagerEngine(
const QMap<QString, QVariant> & parameters,
QGeoServiceProvider::Error * error,
};
#endif // OSMMAPSERVICEPROVIDERFACTORY_H
#header for my plugin class
#ifndef OSMMAPSERVICEPROVIDERFACTORY_H
#define OSMMAPSERVICEPROVIDERFACTORY_H
#include <QGeoServiceProviderFactory>
#include "osmmappingmanagerengine.h"
using namespace QtMobility;
class OsmMapServiceProviderFactory : public QObject, public QGeoServiceProviderFactory
{
//QObject is needed for Q_EXPORT_PLUGIN2 - it works only with QObject derived classes,
//and QGeoServiceProviderFactory is not one of them.
Q_OBJECT
public:
explicit OsmMapServiceProviderFactory();
QString providerName() const {return "mlosm";}
int providerVersion() const {return 1; }
QGeoMappingManagerEngine* createMappingManagerEngine(
const QMap<QString, QVariant> & parameters,
QGeoServiceProvider::Error * error,
QString * errorString ) const;
};
#endif // OSMMAPSERVICEPROVIDERFACTORY_H
To copy to clipboard, switch view to plain text mode
#implementation for my plugin class
#include "osmmapserviceproviderfactory.h"
OsmMapServiceProviderFactory::OsmMapServiceProviderFactory()
{}
QGeoMappingManagerEngine *
OsmMapServiceProviderFactory::createMappingManagerEngine(
const QMap<QString, QVariant> ¶meters,
QGeoServiceProvider::Error *error,
{
return new OsmMappingManagerEngine(parameters,0);
}
Q_EXPORT_PLUGIN2(qtgeoservices_mlosm, OsmMapServiceProviderFactory)
#implementation for my plugin class
#include "osmmapserviceproviderfactory.h"
OsmMapServiceProviderFactory::OsmMapServiceProviderFactory()
{}
QGeoMappingManagerEngine *
OsmMapServiceProviderFactory::createMappingManagerEngine(
const QMap<QString, QVariant> ¶meters,
QGeoServiceProvider::Error *error,
QString *errorString) const
{
return new OsmMappingManagerEngine(parameters,0);
}
Q_EXPORT_PLUGIN2(qtgeoservices_mlosm, OsmMapServiceProviderFactory)
To copy to clipboard, switch view to plain text mode
When building a project, the file /mybin/qt474_custom/plugins/geoservices/libqtgeoservices_mlosm.so is created, as expected. To be on save side, I copy it to /mybin/qtmobility12_custom_forqt474/plugins/geoservices/ where libqtgeoservices_nokia.so (default nokia plugin) was put after I compiled and installed qtmobility.
In different project
qDebug()<<a.libraryPaths();
QApplication a(argc, argv);
qDebug()<<a.libraryPaths();
To copy to clipboard, switch view to plain text mode
shows:
("/mybin/qt474_custom/plugins", "/home/pro/tests/mapsdemo-build-desktop-Qt_4_7_4__qt474_custom__Release", "/usr/lib/kde4/plugins")
so the first path contains my plugin file, but
QList<QString> providers = QGeoServiceProvider::availableServiceProviders();
qDebug()<<providers;
QList<QString> providers = QGeoServiceProvider::availableServiceProviders();
qDebug()<<providers;
To copy to clipboard, switch view to plain text mode
shows only ("nokia")
I expected to see ("nokia", "mlosm") and later use
QGeoServiceProvider *serviceProvider2 = new QGeoServiceProvider("mlosm");
What am I doing wrong? As I said earlier, this is my first attempt at writing qt plugin.
Bookmarks