2 #include "shootquery.h"
3 #include "camshooter.h"
5 ShootQuery::ShootQuery(QObject *parent, CamShooter *camShooterSingleton, QMessageAddress remoteAddr) :
8 msgManager = new QMessageManager(this);
9 msgService = new QMessageService(this);
12 this->camShooter = camShooterSingleton;
13 this->remoteAddr = remoteAddr;
14 QObject::connect(camShooter, SIGNAL(fileReady(const QString &)),
15 this, SLOT(slot_imageReady(const QString &)));
16 QObject::connect(msgManager, SIGNAL(messageUpdated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)),
17 this, SLOT(slot_message_updated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)));
21 ShootQuery::~ShootQuery() {
22 qDebug() << "deleting ShotQuery";
24 msgManager->unregisterNotificationFilter(filterId);
25 QObject::disconnect(this, 0, 0, 0);
30 void ShootQuery::slot_imageReady(const QString &filename) {
31 qDebug() << "In slot imageReady";
33 qDebug() << "building mms";
35 response.setType(QMessage::Mms);
36 response.setTo(remoteAddr);
37 qDebug() << "attaching image";
40 response.appendAttachments(paths);
42 qDebug() << "sending message";
43 if (!msgService->send(response)) {
44 qDebug() << "send() failed.";
47 qDebug() << "message" << response.id().toString() << "queued";
48 qDebug() << "response status is" << response.status();
49 filterId = msgManager->registerNotificationFilter(
50 QMessageFilter::byId(response.id()));
55 void ShootQuery::slot_message_updated(const QMessageId &id, const QMessageManager::NotificationFilterIdSet&) {
56 qDebug() << "Message" << id.toString() << "was updated.";
57 QMessage msg = msgManager->message(id);
58 qDebug() << "msg status is" << msg.status();
59 if (msg.standardFolder() == QMessage::SentFolder) {
60 qDebug() << "Message was sent. deleting.";
61 msgManager->removeMessage(msg.id());
62 qDebug() << "Message deleted.";