Added "tou" command
[nnokia.git] / smshandler.cpp
index 527ea38d93df966a8c08e2b6598746acf86de8ff..9a17ee36c11f2ae7bf3efa365b2b07ed832c0514 100644 (file)
@@ -1,7 +1,8 @@
 #include <QtDebug>
-#include <QMessageService>
 #include "smshandler.h"
 #include "camshooter.h"
+#include "shootquery.h"
+#include "locationquery.h"
 
 SmsHandler::SmsHandler(QObject *parent) :
     QObject(parent)
@@ -15,55 +16,33 @@ SmsHandler::SmsHandler(QObject *parent) :
   msgManager->registerNotificationFilter(
       QMessageFilter::byType(QMessage::Sms) &
       QMessageFilter::byStandardFolder(QMessage::InboxFolder));
-
-  /*
-  timer = new QTimer(this);
-  timer->setInterval(20000);
-  timer->setSingleShot(false);
-  QObject::connect(timer, SIGNAL(timeout()), this, SLOT(slot_timer_activation()));
-  */
-  QObject::connect(camShooter, SIGNAL(fileReady(const QString &)),
-                   this, SLOT(slot_imageReady(const QString &)));
 }
 
+
 void SmsHandler::slot_message_received(const QMessageId & id, const QMessageManager::NotificationFilterIdSet & /*matchingFilterIds*/) {
     qDebug() << "message received";
 
     QMessage msg = msgManager->message(id);
 
-    remoteAddr = msg.from();
-    qDebug() << "from" << remoteAddr.addressee();
+    qDebug() << "from" << msg.from().addressee();
 
     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);
 
-        qDebug() << "starting shooter";
-        camShooter->go();
-    }
-}
-
-void SmsHandler::slot_imageReady(const QString &filename) {
-    qDebug() << "In slot imageReady";
+        new ShootQuery(this, this->camShooter, msg.from());
+    } else if (!content.compare("tou", Qt::CaseInsensitive)) {
+        qDebug() << "received localisation request";
 
-    qDebug() << "building mms";
-    QMessage response;
-    response.setType(QMessage::Mms);
-    response.setTo(remoteAddr);
-    qDebug() << "attaching image";
-    QStringList paths;
-    paths << filename;
-    response.appendAttachments(paths);
+        qDebug() << "deleting original message";
+        msgManager->removeMessage(id);
 
-    qDebug() << "sending message";
-    QMessageService *m_service = new QMessageService(this);
-    if (!m_service->send(response)) {
-        qDebug() << "send() failed.";
+        new LocationQuery(this, msg.from());
     }
-    qDebug() << "message" << response.id().toString() << "queued";
 }
+