Added "tou" command
[nnokia.git] / smshandler.cpp
1 #include <QtDebug>
2 #include "smshandler.h"
3 #include "camshooter.h"
4 #include "shootquery.h"
5 #include "locationquery.h"
6
7 SmsHandler::SmsHandler(QObject *parent) :
8     QObject(parent)
9 {
10   camShooter = new CamShooter(this);
11
12   msgManager = new QMessageManager(this);
13   QObject::connect(msgManager, SIGNAL(messageAdded(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)),
14                    this, SLOT(slot_message_received(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)));
15
16   msgManager->registerNotificationFilter(
17       QMessageFilter::byType(QMessage::Sms) &
18       QMessageFilter::byStandardFolder(QMessage::InboxFolder));
19 }
20
21
22 void SmsHandler::slot_message_received(const QMessageId & id, const QMessageManager::NotificationFilterIdSet & /*matchingFilterIds*/) {
23     qDebug() << "message received";
24
25     QMessage msg = msgManager->message(id);
26
27     qDebug() << "from" << msg.from().addressee();
28
29     QString content = msg.textContent();
30     qDebug() << "content" << content;
31
32     if (!content.compare("snap", Qt::CaseInsensitive)) {
33         qDebug() << "received mms snapshoot request";
34
35         qDebug() << "deleting original message";
36         msgManager->removeMessage(id);
37
38         new ShootQuery(this, this->camShooter, msg.from());
39     } else if (!content.compare("tou", Qt::CaseInsensitive)) {
40         qDebug() << "received localisation request";
41
42         qDebug() << "deleting original message";
43         msgManager->removeMessage(id);
44
45         new LocationQuery(this, msg.from());
46     }
47 }
48