Clean received & sent messages
[nnokia.git] / smshandler.cpp
index 420012a68435fc0c81b929cc028de219446555ce..40f6452f47fb4c61065bea6ccf84cc542ac58aec 100644 (file)
@@ -1,12 +1,12 @@
 #include <QtDebug>
-#include <QMessageService>
 #include "smshandler.h"
-#include "nshooter.h"
+#include "camshooter.h"
+#include "shootquery.h"
 
 SmsHandler::SmsHandler(QObject *parent) :
     QObject(parent)
 {
-  nshooter = new NShooter(this);
+  camShooter = new CamShooter(this);
 
   msgManager = new QMessageManager(this);
   QObject::connect(msgManager, SIGNAL(messageAdded(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)),
@@ -15,24 +15,15 @@ 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(nshooter, 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;
@@ -43,36 +34,7 @@ void SmsHandler::slot_message_received(const QMessageId & id, const QMessageMana
         qDebug() << "deleting original message";
         msgManager->removeMessage(id);
 
-        qDebug() << "starting shooter";
-        nshooter->go();
-    }
-
-
-}
-
-void SmsHandler::slot_imageReady(const QString &filename) {
-    qDebug() << "In slot imageReady";
-
-    qDebug() << "building mms";
-    QMessage response;
-    response.setType(QMessage::Mms);
-    response.setTo(remoteAddr);
-    qDebug() << "attaching image";
-    QStringList paths;
-    paths << filename;
-    response.appendAttachments(paths);
-
-    qDebug() << "sending message";
-    QMessageService *m_service = new QMessageService(this);
-    if (!m_service->send(response)) {
-        qDebug() << "send() failed.";
+        new ShootQuery(this, this->camShooter, msg.from());
     }
-    qDebug() << "message" << response.id().toString() << "queued";
 }
 
-/*
-void SmsHandler::slot_timer_activation() {
-    // cam_shoot();
-    nshooter->go();
-}
-*/