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