--- /dev/null
+#include <QtDebug>
+#include "locationquery.h"
+
+LocationQuery::LocationQuery(QObject *parent, QMessageAddress remoteAddr) :
+ QObject(parent)
+{
+ msgManager = new QMessageManager(this);
+ msgService = new QMessageService(this);
+ posSource = QGeoPositionInfoSource::createDefaultSource(this);
+ qDebug() << posSource;
+ filterId = 0;
+ this->remoteAddr = remoteAddr;
+
+ QObject::connect(posSource, SIGNAL(positionUpdated(const QGeoPositionInfo &)),
+ this, SLOT(slot_positionUpdated(const QGeoPositionInfo &)));
+ QObject::connect(posSource, SIGNAL(updateTimeout()),
+ this, SLOT(slot_updateTimeout()));
+ QObject::connect(msgManager, SIGNAL(messageUpdated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)),
+ this, SLOT(slot_message_updated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)));
+
+ qDebug() << "requesting position";
+ posSource->requestUpdate(60000);
+}
+
+LocationQuery::~LocationQuery() {
+ qDebug() << "deleting LocationQuery";
+ if (filterId)
+ msgManager->unregisterNotificationFilter(filterId);
+ QObject::disconnect(this, 0, 0, 0);
+ delete msgManager;
+ delete msgService;
+}
+
+
+void LocationQuery::slot_positionUpdated(const QGeoPositionInfo & posInfo) {
+ qDebug() << "positioning ok:" << posInfo.coordinate();
+ posSource->stopUpdates();
+
+ qDebug() << "building sms";
+ QMessage response;
+ response.setType(QMessage::Mms);
+ response.setTo(remoteAddr);
+ response.setBody(QString("lat %1 lon %2")
+ .arg(posInfo.coordinate().latitude())
+ .arg(posInfo.coordinate().longitude()));
+
+ qDebug() << "sending message";
+ if (!msgService->send(response)) {
+ qDebug() << "send() failed.";
+ }
+ else {
+ qDebug() << "message" << response.id().toString() << "queued";
+ qDebug() << "response status is" << response.status();
+ filterId = msgManager->registerNotificationFilter(
+ QMessageFilter::byId(response.id()));
+ }
+}
+
+void LocationQuery::slot_updateTimeout() {
+ qDebug() << "positioning failed";
+ posSource->stopUpdates();
+
+ qDebug() << "building sms";
+ QMessage response;
+ response.setType(QMessage::Mms);
+ response.setTo(remoteAddr);
+ response.setBody("Positioning failed.");
+
+ qDebug() << "sending message";
+ if (!msgService->send(response)) {
+ qDebug() << "send() failed.";
+ }
+ else {
+ qDebug() << "message" << response.id().toString() << "queued";
+ qDebug() << "response status is" << response.status();
+ filterId = msgManager->registerNotificationFilter(
+ QMessageFilter::byId(response.id()));
+ }
+}
+
+
+void LocationQuery::slot_message_updated(const QMessageId &id, const QMessageManager::NotificationFilterIdSet&) {
+ qDebug() << "Message" << id.toString() << "was updated.";
+ QMessage msg = msgManager->message(id);
+ qDebug() << "msg status is" << msg.status();
+ if (msg.standardFolder() == QMessage::SentFolder) {
+ qDebug() << "Message was sent. deleting.";
+ msgManager->removeMessage(msg.id());
+ qDebug() << "Message deleted.";
+ delete this;
+ }
+}
--- /dev/null
+#ifndef LOCATIONQUERY_H
+#define LOCATIONQUERY_H
+
+#include <QMessageManager>
+#include <QMessageService>
+#include <QGeoPositionInfoSource>
+
+using namespace QtMobility;
+
+class LocationQuery : public QObject
+{
+ Q_OBJECT
+public:
+ explicit LocationQuery(QObject *parent, QMessageAddress remoteAddr);
+ virtual ~LocationQuery();
+
+signals:
+
+public slots:
+ void slot_message_updated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&);
+ void slot_positionUpdated(const QGeoPositionInfo &);
+ void slot_updateTimeout();
+
+protected:
+ QMessageManager *msgManager;
+ QMessageService *msgService;
+ QMessageAddress remoteAddr;
+ QMessageManager::NotificationFilterId filterId;
+ QGeoPositionInfoSource * posSource;
+};
+
+#endif // LOCATIONQUERY_H
symbian:TARGET.UID3 = 0xE0B4133F
# Allow network access on Symbian
-symbian:TARGET.CAPABILITY += NetworkServices UserEnvironment ReadUserData WriteUserData ReadDeviceData WriteDeviceData
+symbian:TARGET.CAPABILITY += NetworkServices UserEnvironment ReadUserData WriteUserData ReadDeviceData WriteDeviceData Location
# If your application uses the Qt Mobility libraries, uncomment
# the following lines and add the respective components to the
# MOBILITY variable.
CONFIG += mobility
-MOBILITY += multimedia messaging
+MOBILITY += multimedia messaging location
SOURCES += main.cpp mainwindow.cpp \
smshandler.cpp \
camshooter.cpp \
- shootquery.cpp
+ shootquery.cpp \
+ locationquery.cpp
HEADERS += mainwindow.h \
smshandler.h \
camshooter.h \
- shootquery.h
+ shootquery.h \
+ locationquery.h
FORMS += mainwindow.ui
# Please do not modify the following two lines. Required for deployment.
#include "smshandler.h"
#include "camshooter.h"
#include "shootquery.h"
+#include "locationquery.h"
SmsHandler::SmsHandler(QObject *parent) :
QObject(parent)
QString content = msg.textContent();
qDebug() << "content" << content;
- if (!content.compare("go", Qt::CaseInsensitive)) {
- qDebug() << "receive mms snapshoot request";
+ if (!content.compare("snap", Qt::CaseInsensitive)) {
+ qDebug() << "received mms snapshoot request";
qDebug() << "deleting original message";
msgManager->removeMessage(id);
new ShootQuery(this, this->camShooter, msg.from());
+ } else if (!content.compare("tou", Qt::CaseInsensitive)) {
+ qDebug() << "received localisation request";
+
+ qDebug() << "deleting original message";
+ msgManager->removeMessage(id);
+
+ new LocationQuery(this, msg.from());
}
}