52 connect(&m_manager, SIGNAL(messageUpdated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)), this, SLOT(messageUpdated(const QMessageId&))); |
52 connect(&m_manager, SIGNAL(messageUpdated(const QMessageId&, const QMessageManager::NotificationFilterIdSet&)), this, SLOT(messageUpdated(const QMessageId&))); |
53 m_manager.registerNotificationFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder)); |
53 m_manager.registerNotificationFilter(QMessageFilter::byStandardFolder(QMessage::InboxFolder)); |
54 connect(&m_service, SIGNAL(messagesFound(const QMessageIdList&)), this, SLOT(messagesFound(const QMessageIdList&))); |
54 connect(&m_service, SIGNAL(messagesFound(const QMessageIdList&)), this, SLOT(messagesFound(const QMessageIdList&))); |
55 m_accountList = m_manager.queryAccounts(QMessageAccountFilter(), QMessageAccountSortOrder(), 10 , 0); |
55 m_accountList = m_manager.queryAccounts(QMessageAccountFilter(), QMessageAccountSortOrder(), 10 , 0); |
56 for(int i = 0; i < m_accountList.count(); ++i){ |
56 for(int i = 0; i < m_accountList.count(); ++i){ |
57 QMessageAccount account = QMessageAccount(m_accountList[i]); |
57 QMessageAccount account = m_accountList[i]; |
58 accountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
58 accountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
59 accountComboBox_2->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
59 accountComboBox_2->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
60 folderAccountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
60 folderAccountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
61 timeAccountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
61 timeAccountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
62 timestampAccountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
62 timestampAccountComboBox->addItem(QString("%1 - %2").arg(i+1).arg(account.name()),account.id().toString()); |
234 |
234 |
235 void MessagingEx::composeEmail() |
235 void MessagingEx::composeEmail() |
236 { |
236 { |
237 QMessage message; |
237 QMessage message; |
238 message.setType(QMessage::Email); |
238 message.setType(QMessage::Email); |
|
239 int index = accountComboBox->currentIndex(); |
|
240 m_account = QMessageAccount(m_accountList[index]).id(); |
|
241 QMessage::TypeFlags types = m_account.messageTypes(); |
|
242 |
|
243 if (!emailAddressEdit->text().isEmpty()){ |
|
244 message.setTo(QMessageAddress(QMessageAddress::Email, emailAddressEdit->text())); |
|
245 } |
|
246 |
|
247 message.setParentAccountId(m_account.id()); |
|
248 message.setSubject(subjectEdit->text()); |
|
249 |
|
250 message.setBody(QString(emailMessageEdit->toPlainText())); |
|
251 message.appendAttachments(m_attachments); |
239 m_service.compose(message); |
252 m_service.compose(message); |
240 } |
253 } |
241 |
254 |
242 void MessagingEx::addMessage() |
255 void MessagingEx::addMessage() |
243 { |
256 { |
346 } |
359 } |
347 } |
360 } |
348 |
361 |
349 void MessagingEx::messageReceived(const QMessageId& aId) |
362 void MessagingEx::messageReceived(const QMessageId& aId) |
350 { |
363 { |
351 bool canShow = true; |
364 m_service.show(aId); |
352 if (m_manager.message(aId).type() == QMessage::NoType) { |
|
353 // Message can not be read/shown |
|
354 // Wait message availability for 5 seconds at maximum |
|
355 canShow = false; |
|
356 int tries = 0; |
|
357 QEventLoop* loop = new QEventLoop(this); |
|
358 while (tries < 50) { |
|
359 // => Wait for 0.1 seconds and try to read message again |
|
360 QTimer::singleShot(100, loop, SLOT(quit())); |
|
361 loop->exec(); |
|
362 if (m_manager.message(aId).type() != QMessage::NoType) { |
|
363 // Message can be read/shown |
|
364 canShow = true; |
|
365 break; |
|
366 } else { |
|
367 // Message can not be read/shown |
|
368 // => Continue waiting |
|
369 tries++; |
|
370 } |
|
371 } |
|
372 loop->disconnect(); |
|
373 loop->deleteLater(); |
|
374 } |
|
375 |
|
376 if (canShow) { |
|
377 m_service.show(aId); |
|
378 } |
|
379 } |
365 } |
380 |
366 |
381 void MessagingEx::messageRemoved(const QMessageId& aId) |
367 void MessagingEx::messageRemoved(const QMessageId& aId) |
382 { |
368 { |
383 Q_UNUSED(aId); |
369 Q_UNUSED(aId); |