src/messaging/qmessageservice_qmf.cpp
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 #include "qmessageservice.h"
       
    42 #include "qmfhelpers_p.h"
       
    43 
       
    44 #include <qmailserviceaction.h>
       
    45 
       
    46 #include <QTimer>
       
    47 #include <qmessage_p.h>
       
    48 
       
    49 
       
    50 QTM_BEGIN_NAMESPACE
       
    51 
       
    52 namespace {
       
    53 
       
    54 struct TextPartSearcher
       
    55 {
       
    56     QString _search;
       
    57 
       
    58     TextPartSearcher(const QString &searchText) : _search(searchText) {}
       
    59 
       
    60     bool operator()(const QMailMessagePart &part)
       
    61     {
       
    62         if (part.contentType().type().toLower() == "text") {
       
    63             if (part.body().data().contains(_search, Qt::CaseInsensitive)) {
       
    64                 // We have located some matching text - stop the traversal
       
    65                 return false;
       
    66             }
       
    67         }
       
    68 
       
    69         return true;
       
    70     }
       
    71 };
       
    72 
       
    73 }
       
    74 
       
    75 using namespace QmfHelpers;
       
    76 
       
    77 class QMessageServicePrivate : public QObject
       
    78 {
       
    79     Q_OBJECT
       
    80 
       
    81 public:
       
    82     QMessageServicePrivate();
       
    83 
       
    84     QMailTransmitAction _transmit;
       
    85     QMailRetrievalAction _retrieval;
       
    86     QMailServiceAction *_active;
       
    87     QMessageManager::Error _error;
       
    88     bool _activeStoreAction;
       
    89 
       
    90     QList<QMessageId> _matchingIds;
       
    91     QList<QMailMessageId> _candidateIds;
       
    92     QMessageFilter _lastFilter;
       
    93     QMessageSortOrder _lastOrdering;
       
    94     QString _match;
       
    95     int _limit;
       
    96     int _offset;
       
    97 
       
    98     QMailMessageIdList _transmitIds;
       
    99     
       
   100     bool isBusy() const;
       
   101 
       
   102 signals:
       
   103     void stateChanged(QMessageService::State);
       
   104     void progressChanged(uint, uint);
       
   105     void messagesFound(const QMessageIdList&);
       
   106     void messagesCounted(int);
       
   107 
       
   108 protected slots:
       
   109     void transmitActivityChanged(QMailServiceAction::Activity a);
       
   110     void retrievalActivityChanged(QMailServiceAction::Activity a);
       
   111     void statusChanged(const QMailServiceAction::Status &s);
       
   112     void completed();
       
   113     void reportMatchingIds();
       
   114     void reportMatchingCount();
       
   115     void findMatchingIds();
       
   116     void testNextMessage();
       
   117 
       
   118 private:
       
   119     bool messageMatch(const QMailMessageId &messageid);
       
   120 };
       
   121 
       
   122 QMessageServicePrivate::QMessageServicePrivate()
       
   123     : QObject(),
       
   124       _active(0),
       
   125       _error(QMessageManager::NoError),
       
   126       _activeStoreAction(false),
       
   127       _limit(0),
       
   128       _offset(0)
       
   129 {
       
   130     connect(&_transmit, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(transmitActivityChanged(QMailServiceAction::Activity)));
       
   131     connect(&_transmit, SIGNAL(statusChanged(QMailServiceAction::Status)), this, SLOT(statusChanged(QMailServiceAction::Status)));
       
   132 
       
   133     connect(&_retrieval, SIGNAL(activityChanged(QMailServiceAction::Activity)), this, SLOT(retrievalActivityChanged(QMailServiceAction::Activity)));
       
   134     connect(&_retrieval, SIGNAL(statusChanged(QMailServiceAction::Status)), this, SLOT(statusChanged(QMailServiceAction::Status)));
       
   135 }
       
   136 
       
   137 bool QMessageServicePrivate::isBusy() const
       
   138 {
       
   139     if ((_active && ((_active->activity() == QMailServiceAction::Pending) || (_active->activity() == QMailServiceAction::InProgress))) ||
       
   140         _activeStoreAction) {
       
   141         qWarning() << "Action is currently busy";
       
   142         return true;
       
   143     }
       
   144 
       
   145     return false;
       
   146 }
       
   147 
       
   148 void QMessageServicePrivate::transmitActivityChanged(QMailServiceAction::Activity a)
       
   149 {
       
   150     if (a == QMailServiceAction::Successful) {
       
   151         if (!_transmitIds.isEmpty()) {
       
   152             // If these messages were transmitted, we need to move them to Sent folder
       
   153             QMailMessageKey filter(QMailMessageKey::id(_transmitIds));
       
   154             foreach (const QMailMessageId &id, QMailStore::instance()->queryMessages(filter & QMailMessageKey::status(QMailMessage::Sent))) {
       
   155                 QMessage message(convert(id));
       
   156 
       
   157                 QMessagePrivate::setStandardFolder(message,QMessage::SentFolder);
       
   158                 if (!QMessageManager().updateMessage(&message)) {
       
   159                     qWarning() << "Unable to mark message as sent!";
       
   160                 }
       
   161             }
       
   162 
       
   163             _transmitIds.clear();
       
   164         }
       
   165     } else if (a == QMailServiceAction::Failed) {
       
   166         _transmitIds.clear();
       
   167 
       
   168         if (_error == QMessageManager::NoError) {
       
   169             // We may have failed due to some part of the request remaining incomplete
       
   170             _error = QMessageManager::RequestIncomplete;
       
   171         }
       
   172     }
       
   173 
       
   174     emit stateChanged(convert(a));
       
   175 }
       
   176 
       
   177 void QMessageServicePrivate::statusChanged(const QMailServiceAction::Status &s)
       
   178 {
       
   179     if (s.errorCode != QMailServiceAction::Status::ErrNoError) {
       
   180         qWarning() << QString("Service error %1: \"%2\"").arg(s.errorCode).arg(s.text);
       
   181 
       
   182         if (s.errorCode == QMailServiceAction::Status::ErrNotImplemented) {
       
   183             _error = QMessageManager::NotYetImplemented;
       
   184         } else if ((s.errorCode == QMailServiceAction::Status::ErrNonexistentMessage) ||
       
   185                    (s.errorCode == QMailServiceAction::Status::ErrEnqueueFailed) ||
       
   186                    (s.errorCode == QMailServiceAction::Status::ErrInvalidAddress) ||
       
   187                    (s.errorCode == QMailServiceAction::Status::ErrInvalidData)) {
       
   188             _error = QMessageManager::ConstraintFailure;
       
   189         } else {
       
   190             _error = QMessageManager::FrameworkFault;
       
   191         }
       
   192     }
       
   193 }
       
   194 
       
   195 void QMessageServicePrivate::retrievalActivityChanged(QMailServiceAction::Activity a)
       
   196 {
       
   197     if ((a == QMailServiceAction::Failed) && (_error == QMessageManager::NoError)) {
       
   198         // We may have failed due to some part of the request remaining incomplete
       
   199         _error = QMessageManager::RequestIncomplete;
       
   200     }
       
   201 
       
   202     emit stateChanged(convert(a));
       
   203 }
       
   204 
       
   205 void QMessageServicePrivate::completed()
       
   206 {
       
   207     _activeStoreAction = false;
       
   208     emit stateChanged(QMessageService::FinishedState);
       
   209 }
       
   210 
       
   211 bool QMessageServicePrivate::messageMatch(const QMailMessageId &messageId)
       
   212 {
       
   213     if (_match.isEmpty()) {
       
   214         return true;
       
   215     }
       
   216 
       
   217     const QMailMessage candidate(messageId);
       
   218     if (candidate.id().isValid()) {
       
   219         // Search only messages or message parts that are of type 'text/*'
       
   220         if (candidate.hasBody()) {
       
   221             if (candidate.contentType().type().toLower() == "text") {
       
   222                 if (candidate.body().data().contains(_match, Qt::CaseInsensitive))
       
   223                     return true;
       
   224             }
       
   225         } else if (candidate.multipartType() != QMailMessage::MultipartNone) {
       
   226             // Search all 'text/*' parts within this message
       
   227             TextPartSearcher searcher(_match);
       
   228             if (candidate.foreachPart<TextPartSearcher&>(searcher) == false) {
       
   229                 // We found a matching part in the message
       
   230                 return true;
       
   231             }
       
   232         }
       
   233     }
       
   234 
       
   235     return false;
       
   236 }
       
   237 
       
   238 void QMessageServicePrivate::reportMatchingIds()
       
   239 {
       
   240     emit messagesFound(convert(_candidateIds));
       
   241     completed();
       
   242 }
       
   243 
       
   244 void QMessageServicePrivate::reportMatchingCount()
       
   245 {
       
   246     emit messagesCounted(_candidateIds.count());
       
   247     completed();
       
   248 }
       
   249 
       
   250 void QMessageServicePrivate::findMatchingIds()
       
   251 {
       
   252     int required = ((_offset + _limit) - _matchingIds.count());
       
   253 
       
   254     // Are any of the existing IDs part of the result set?
       
   255     if (required < _limit) {
       
   256         emit messagesFound(_matchingIds.mid(_offset, _limit));
       
   257     }
       
   258 
       
   259     if ((required > 0 || _limit == 0) && !_candidateIds.isEmpty()) {
       
   260         QTimer::singleShot(0, this, SLOT(testNextMessage()));
       
   261     } else {
       
   262         completed();
       
   263     }
       
   264 }
       
   265 
       
   266 void QMessageServicePrivate::testNextMessage()
       
   267 {
       
   268     int required = ((_offset + _limit) - _matchingIds.count());
       
   269     if (required > 0 || _limit==0) {
       
   270         QMailMessageId messageId(_candidateIds.takeFirst());
       
   271         if (messageMatch(messageId)) {
       
   272             _matchingIds.append(convert(messageId));
       
   273             --required;
       
   274 
       
   275             if (required < _limit) {
       
   276                 // This is within the result set
       
   277                 emit messagesFound(QMessageIdList() << _matchingIds.last());
       
   278             }
       
   279         }
       
   280 
       
   281         if ((required > 0 || _limit == 0) && !_candidateIds.isEmpty()) {
       
   282             QTimer::singleShot(0, this, SLOT(testNextMessage()));
       
   283             return;
       
   284         }
       
   285     }
       
   286 
       
   287     completed();
       
   288 }
       
   289 
       
   290 QMessageService::QMessageService(QObject *parent)
       
   291     : QObject(parent),
       
   292       d_ptr(new QMessageServicePrivate)
       
   293 {
       
   294     // Ensure the message store is initialized
       
   295     QMessageManager();
       
   296 
       
   297     connect(d_ptr, SIGNAL(stateChanged(QMessageService::State)), 
       
   298             this, SIGNAL(stateChanged(QMessageService::State)));
       
   299     connect(d_ptr, SIGNAL(messagesFound(QMessageIdList)), 
       
   300             this, SIGNAL(messagesFound(QMessageIdList)));
       
   301     connect(d_ptr, SIGNAL(messagesCounted(int)), 
       
   302             this, SIGNAL(messagesCounted(int)));
       
   303     connect(d_ptr, SIGNAL(progressChanged(uint, uint)), 
       
   304             this, SIGNAL(progressChanged(uint, uint)));
       
   305 }
       
   306 
       
   307 QMessageService::~QMessageService()
       
   308 {
       
   309     delete d_ptr;
       
   310 }
       
   311 
       
   312 bool QMessageService::queryMessages(const QMessageFilter &filter, const QMessageSortOrder &sortOrder, uint limit, uint offset)
       
   313 {
       
   314     if (d_ptr->isBusy()) {
       
   315         return false;
       
   316     }
       
   317     d_ptr->_active = 0;
       
   318     d_ptr->_activeStoreAction = true;
       
   319     emit stateChanged(QMessageService::ActiveState);
       
   320 
       
   321     d_ptr->_candidateIds = QMailStore::instance()->queryMessages(convert(filter), convert(sortOrder), limit, offset);
       
   322     d_ptr->_error = convert(QMailStore::instance()->lastError());
       
   323 
       
   324     if (d_ptr->_error == QMessageManager::NoError) {
       
   325         d_ptr->_lastFilter = QMessageFilter();
       
   326         d_ptr->_lastOrdering = QMessageSortOrder();
       
   327         d_ptr->_match = QString();
       
   328         d_ptr->_limit = static_cast<int>(limit);
       
   329         d_ptr->_offset = 0;
       
   330         d_ptr->_matchingIds.clear();
       
   331         QTimer::singleShot(0, d_ptr, SLOT(reportMatchingIds()));
       
   332         return true;
       
   333     }
       
   334 
       
   335     return false;
       
   336 }
       
   337 
       
   338 bool QMessageService::queryMessages(const QMessageFilter &filter, const QString &body, QMessageDataComparator::MatchFlags matchFlags, const QMessageSortOrder &sortOrder, uint limit, uint offset)
       
   339 {
       
   340     if (matchFlags) {
       
   341         //TODO: Support matchFlags
       
   342         return false;
       
   343     }
       
   344 
       
   345     if (body.isEmpty()) {
       
   346         return queryMessages(filter, sortOrder, limit, offset);
       
   347     }
       
   348 
       
   349     if (d_ptr->isBusy()) {
       
   350         return false;
       
   351     }
       
   352 
       
   353     d_ptr->_active = 0;
       
   354     d_ptr->_activeStoreAction = true;
       
   355     emit stateChanged(QMessageService::ActiveState);
       
   356 
       
   357     if ((filter == d_ptr->_lastFilter) && (sortOrder == d_ptr->_lastOrdering) && (body == d_ptr->_match)) {
       
   358         // This is a continuation of the last search
       
   359         d_ptr->_limit = static_cast<int>(limit);
       
   360         d_ptr->_offset = static_cast<int>(offset);
       
   361         QTimer::singleShot(0, d_ptr, SLOT(findMatchingIds()));
       
   362         return true;
       
   363     }
       
   364 
       
   365     // Find all messages to perform the body search on
       
   366     d_ptr->_candidateIds = QMailStore::instance()->queryMessages(convert(filter), convert(sortOrder));
       
   367     d_ptr->_error = convert(QMailStore::instance()->lastError());
       
   368 
       
   369     if (d_ptr->_error == QMessageManager::NoError) {
       
   370         d_ptr->_lastFilter = filter;
       
   371         d_ptr->_lastOrdering = sortOrder;
       
   372         d_ptr->_match = body;
       
   373         d_ptr->_limit = static_cast<int>(limit);
       
   374         d_ptr->_offset = static_cast<int>(offset);
       
   375         d_ptr->_matchingIds.clear();
       
   376         QTimer::singleShot(0, d_ptr, SLOT(findMatchingIds()));
       
   377         return true;
       
   378     }
       
   379 
       
   380     return false;
       
   381 }
       
   382 
       
   383 bool QMessageService::countMessages(const QMessageFilter &filter)
       
   384 {
       
   385     if (d_ptr->isBusy()) {
       
   386         return false;
       
   387     }
       
   388     d_ptr->_active = 0;
       
   389     d_ptr->_activeStoreAction = true;
       
   390     
       
   391     d_ptr->_candidateIds = QMailStore::instance()->queryMessages(convert(filter));
       
   392     d_ptr->_error = convert(QMailStore::instance()->lastError());
       
   393 
       
   394     if (d_ptr->_error == QMessageManager::NoError) {
       
   395         d_ptr->_lastFilter = QMessageFilter();
       
   396         d_ptr->_lastOrdering = QMessageSortOrder();
       
   397         d_ptr->_match = QString();
       
   398         d_ptr->_limit = 0;
       
   399         d_ptr->_offset = 0;
       
   400         d_ptr->_matchingIds.clear();
       
   401         QTimer::singleShot(0, d_ptr, SLOT(reportMatchingCount()));
       
   402         return true;
       
   403     }
       
   404 
       
   405     return false;
       
   406 }
       
   407 
       
   408 bool QMessageService::send(QMessage &message)
       
   409 {
       
   410     if (d_ptr->isBusy()) {
       
   411         return false;
       
   412     }
       
   413     d_ptr->_active = 0;
       
   414 
       
   415     if (!message.parentAccountId().isValid()) {
       
   416         // Attach to the default account
       
   417         message.setParentAccountId(QMessageAccount::defaultAccount(message.type()));
       
   418         if (!message.parentAccountId().isValid()) {
       
   419             d_ptr->_error = QMessageManager::InvalidId;
       
   420             qWarning() << "Invalid message account ID";
       
   421             return false;
       
   422         }
       
   423     }
       
   424 
       
   425     // Ensure the message contains a timestamp
       
   426     if (!message.date().isValid()) {
       
   427         message.setDate(QDateTime::currentDateTime());
       
   428     }
       
   429 
       
   430     QMessageFolderId existingFolderId(message.parentFolderId());
       
   431 
       
   432     // Move the message to the Outbox folder
       
   433     QMessagePrivate::setStandardFolder(message,QMessage::OutboxFolder);
       
   434 
       
   435     QMailMessage *msg(convert(&message));
       
   436 
       
   437     // Ensure that the from address is added
       
   438     if (msg->from().isNull()) {
       
   439         QMailAccount account(msg->parentAccountId());
       
   440         msg->setFrom(account.fromAddress());
       
   441     }
       
   442 
       
   443     // Mark this message as outgoing
       
   444     msg->setStatus(QMailMessage::Outbox, true);
       
   445 
       
   446     if (msg->id().isValid()) {
       
   447         // Update the message
       
   448         if (!QMailStore::instance()->updateMessage(msg)) {
       
   449             d_ptr->_error = QMessageManager::FrameworkFault;
       
   450             qWarning() << "Unable to mark message as outgoing";
       
   451             return false;
       
   452         }
       
   453     } else {
       
   454         // Add this message to the store
       
   455         if (!QMailStore::instance()->addMessage(msg)) {
       
   456             d_ptr->_error = QMessageManager::FrameworkFault;
       
   457             qWarning() << "Unable to store message for transmission";
       
   458             return false;
       
   459         }
       
   460     }
       
   461 
       
   462     d_ptr->_transmitIds = QMailStore::instance()->queryMessages(QMailMessageKey::status(QMailMessage::Outgoing) & QMailMessageKey::parentAccountId(msg->parentAccountId()));
       
   463 
       
   464     d_ptr->_error = QMessageManager::NoError;
       
   465     d_ptr->_active = &d_ptr->_transmit;
       
   466     d_ptr->_transmit.transmitMessages(msg->parentAccountId());
       
   467     return true;
       
   468 }
       
   469 
       
   470 bool QMessageService::compose(const QMessage &message)
       
   471 {
       
   472     if (d_ptr->isBusy()) {
       
   473         return false;
       
   474     }
       
   475     d_ptr->_active = 0;
       
   476 
       
   477     // TODO: To be implemented by integrator
       
   478     d_ptr->_error = QMessageManager::NotYetImplemented;
       
   479     qWarning() << "QMessageService::compose not yet implemented";
       
   480     return false;
       
   481 
       
   482     Q_UNUSED(message)
       
   483 }
       
   484 
       
   485 bool QMessageService::retrieveHeader(const QMessageId& id)
       
   486 {
       
   487     if (d_ptr->isBusy()) {
       
   488         return false;
       
   489     }
       
   490     d_ptr->_active = 0;
       
   491 
       
   492     QMailMessageId messageId(convert(id));
       
   493     if (!messageId.isValid()) {
       
   494         d_ptr->_error = QMessageManager::InvalidId;
       
   495         qWarning() << "Invalid message ID";
       
   496         return false;
       
   497     }
       
   498 
       
   499     // Operation is not relevant to QMF - meta data retrieval always includes header information
       
   500     d_ptr->_error = QMessageManager::NoError;
       
   501     d_ptr->_active = 0;
       
   502     QTimer::singleShot(0, d_ptr, SLOT(completed()));
       
   503     return true;
       
   504 }
       
   505 
       
   506 bool QMessageService::retrieveBody(const QMessageId& id)
       
   507 {
       
   508     if (d_ptr->isBusy()) {
       
   509         return false;
       
   510     }
       
   511     d_ptr->_active = 0;
       
   512 
       
   513     QMailMessageId messageId(convert(id));
       
   514     if (!messageId.isValid()) {
       
   515         d_ptr->_error = QMessageManager::InvalidId;
       
   516         qWarning() << "Invalid message ID";
       
   517         return false;
       
   518     }
       
   519 
       
   520     d_ptr->_error = QMessageManager::NoError;
       
   521     d_ptr->_active = &d_ptr->_retrieval;
       
   522     d_ptr->_retrieval.retrieveMessages(QMailMessageIdList() << messageId, QMailRetrievalAction::Content);
       
   523     return true;
       
   524 }
       
   525 
       
   526 bool QMessageService::retrieve(const QMessageId &messageId, const QMessageContentContainerId& id)
       
   527 {
       
   528     if (d_ptr->isBusy()) {
       
   529         return false;
       
   530     }
       
   531     d_ptr->_active = 0;
       
   532 
       
   533     QMailMessagePart::Location location(convert(id));
       
   534     if (!location.isValid()) {
       
   535         d_ptr->_error = QMessageManager::InvalidId;
       
   536         qWarning() << "Invalid message part location";
       
   537         return false;
       
   538     }
       
   539     
       
   540     d_ptr->_error = QMessageManager::NoError;
       
   541     d_ptr->_active = &d_ptr->_retrieval;
       
   542     d_ptr->_retrieval.retrieveMessagePart(location);
       
   543     return true;
       
   544 
       
   545     Q_UNUSED(messageId)
       
   546 }
       
   547 
       
   548 bool QMessageService::show(const QMessageId& id)
       
   549 {
       
   550     if (d_ptr->isBusy()) {
       
   551         return false;
       
   552     }
       
   553     d_ptr->_active = 0;
       
   554 
       
   555     // TODO: To be implemented by integrator
       
   556     d_ptr->_error = QMessageManager::NotYetImplemented;
       
   557     qWarning() << "QMessageService::show not yet implemented";
       
   558     return false;
       
   559 
       
   560     Q_UNUSED(id)
       
   561 }
       
   562 
       
   563 bool QMessageService::exportUpdates(const QMessageAccountId &id)
       
   564 {
       
   565     if (d_ptr->isBusy()) {
       
   566         return false;
       
   567     }
       
   568     d_ptr->_active = 0;
       
   569 
       
   570     QMailAccountId accountId(convert(id));
       
   571     if (!accountId.isValid()) {
       
   572         d_ptr->_error = QMessageManager::InvalidId;
       
   573         qWarning() << "Account ID is not valid";
       
   574         return false;
       
   575     }
       
   576 
       
   577     d_ptr->_error = QMessageManager::NoError;
       
   578     d_ptr->_active = &d_ptr->_retrieval;
       
   579     d_ptr->_retrieval.exportUpdates(accountId);
       
   580     return true;
       
   581 }
       
   582 
       
   583 QMessageService::State QMessageService::state() const
       
   584 {
       
   585     if (d_ptr->_active) {
       
   586         return convert(d_ptr->_active->activity());
       
   587     }
       
   588     else if(d_ptr->_activeStoreAction)
       
   589         return QMessageService::ActiveState;
       
   590 
       
   591     return FinishedState;
       
   592 }
       
   593 
       
   594 void QMessageService::cancel()
       
   595 {
       
   596     if (d_ptr->_active) {
       
   597         d_ptr->_active->cancelOperation();
       
   598     }
       
   599     else if(d_ptr->_activeStoreAction)
       
   600         d_ptr->_activeStoreAction = false;
       
   601 }
       
   602 
       
   603 QMessageManager::Error QMessageService::error() const
       
   604 {
       
   605     return d_ptr->_error;
       
   606 }
       
   607 
       
   608 #include "qmessageservice_qmf.moc"
       
   609 
       
   610 
       
   611 QTM_END_NAMESPACE