src/messaging/qmessageservice.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 #ifdef Q_OS_SYMBIAN
       
    43 #include "qmessageservice_symbian_p.h"
       
    44 #endif
       
    45 
       
    46 
       
    47 QTM_BEGIN_NAMESPACE
       
    48 
       
    49 /*!
       
    50     \class QMessageService
       
    51 
       
    52     \ingroup messaging
       
    53 
       
    54     \brief The QMessageService class provides the interface for requesting 
       
    55     messaging service operations.
       
    56 
       
    57     QMessageService provides the mechanisms for messaging clients to request services, 
       
    58     and to receive information in response.  All requestable service operations present 
       
    59     the same interface for communicating status, and progress information.
       
    60 
       
    61     All service request operations communicate changes in their operational state 
       
    62     by emitting the stateChanged() signal.
       
    63 
       
    64     Service request operations report progress information by emitting the 
       
    65     progressChanged() signal.
       
    66     
       
    67     If a requested operation fails after being initiated then the error() 
       
    68     function will return a value indicating the failure mode encountered.
       
    69     
       
    70     A client may attempt to cancel a requested operation after it has been 
       
    71     initiated. The cancel() slot is provided for this purpose.  Cancelation
       
    72     is not guaranteed to succeed, and is not possible on all platforms.
       
    73 
       
    74     A QMessageService instance supports only a single request at a time. Attempting 
       
    75     to initiate an operation on a QMessageService while another operation is already 
       
    76     in progress will result in function initiating the latter request returning 
       
    77     false. A client may, however, use multiple QMessageService instances to 
       
    78     concurrently initiate a queue of requests that will be serviced sequentially.
       
    79 
       
    80     Each QMessageService instance will report only the changes pertaining to 
       
    81     the request that instance initiated.
       
    82 
       
    83     Except where noted QMessageServices may initiate network activity. 
       
    84     Other functions in the mobility messaging API will not initiate network 
       
    85     activity, with the exception of Windows mobile and desktop platforms which 
       
    86     may initiate network activity during the evaluation of any function call.
       
    87 */
       
    88 
       
    89 /*!
       
    90     \enum QMessageService::State
       
    91 
       
    92     This enum type is used to describe the state of the requested operation.
       
    93 
       
    94     \value InactiveState    The operation has not yet begun execution.
       
    95     \value ActiveState      The operation is currently executing.
       
    96     \value CanceledState    The operation was canceled.
       
    97     \value FinishedState    The operation has finished execution; succesfully completed or otherwise.
       
    98 */
       
    99 
       
   100 /*!
       
   101     \fn QMessageService::QMessageService(QObject *parent)
       
   102   
       
   103     Constructs a message service representation object.
       
   104     
       
   105     The \a parent is passed to the QObject constructor.
       
   106 */
       
   107 
       
   108 /*!
       
   109     \fn QMessageService::~QMessageService()
       
   110   
       
   111     Destroys the message service representation.
       
   112 */
       
   113 
       
   114 /*!
       
   115     \fn QMessageService::queryMessages(const QMessageFilter &filter, const QMessageSortOrder &sortOrder, uint limit, uint offset)
       
   116     
       
   117     Emits via messagesFound() signals \l{QMessageId}s of messages in the messaging 
       
   118     store. If \a filter is not empty only identifiers for messages matching the parameters 
       
   119     set by \a filter will be emitted, otherwise identifiers for all messages will be emitted.
       
   120     If \a sortOrder is not empty, then the identifiers will be sorted by the parameters 
       
   121     set by \a sortOrder.
       
   122     If \a limit is not zero, then \a limit places an upper bound on the number of 
       
   123     ids in the list returned.
       
   124     \a offset specifies how many ids to skip at the beginning of the list returned.
       
   125     
       
   126     Calling this function may result in the messagesFound() and progressChanged() 
       
   127     signals  being emitted multiple times. An emission of the progressChanged()
       
   128     signal with a total of 0 indicates that the number of progress steps is
       
   129     unknown.
       
   130     
       
   131     The performance of querying messages is currently significantly less than 
       
   132     optimal for some querying criteria on some platforms.
       
   133     
       
   134     Returns true if the operation can be initiated; otherwise returns false.
       
   135 
       
   136     Note: This function should not initiate network activity, instead only message data
       
   137     already stored on the device will be used during evaluation of the function.
       
   138     
       
   139     \sa  QMessage, QMessageFilter, QMessageSortOrder, messagesFound(), progressChanged(), countMessages()
       
   140 */
       
   141 
       
   142 /*!
       
   143     \fn QMessageService::queryMessages(const QMessageFilter &filter, const QString &body, QMessageDataComparator::MatchFlags matchFlags, const QMessageSortOrder &sortOrder, uint limit, uint offset)
       
   144     
       
   145     Emits via the messagesFound() signal \l{QMessageId}s of messages in the messaging 
       
   146     store. If \a filter is not empty only identifiers for messages matching the parameters 
       
   147     set by \a filter and with a body containing the string \a body will be emitted, 
       
   148     otherwise identifiers for all messages with a body containing \a body using 
       
   149     matching flags \a matchFlags will be emitted.
       
   150     If \a sortOrder is not empty, then the identifiers will be sorted by the parameters 
       
   151     set by \a sortOrder.
       
   152     If \a limit is not zero, then \a limit places an upper bound on the number of 
       
   153     ids in the list returned.
       
   154     \a offset specifies how many ids to skip at the beginning of the list returned.
       
   155      
       
   156     Calling this function may result in the messagesFound() and progressChanged() 
       
   157     signals being emitted multiple times. An emission of the progressChanged()
       
   158     signal with a total of 0 indicates that the number of progress steps is
       
   159     unknown.
       
   160 
       
   161     The performance of querying messages is currently significantly less than 
       
   162     optimal for some querying criteria on some platforms.
       
   163     
       
   164     Returns true if the operation can be initiated; otherwise returns false.
       
   165     
       
   166     Note: This function should not initiate network activity, instead only message data
       
   167     already stored on the device will be used during evaluation of the function.
       
   168     
       
   169     \sa  QMessage, QMessageFilter, QMessageSortOrder, messagesFound(), progressChanged(), countMessages()
       
   170 */
       
   171 
       
   172 /*!
       
   173     \fn QMessageService::countMessages(const QMessageFilter &filter)
       
   174     
       
   175     Emits via a messagesCounted() signal the number messages in the messaging 
       
   176     store matching \a filter.
       
   177     
       
   178     Calling this function may result in the progressChanged() 
       
   179     signal  being emitted multiple times. An emission of the progressChanged()
       
   180     signal with a total of 0 indicates that the number of progress steps is
       
   181     unknown.
       
   182     
       
   183     The performance of counting messages is currently significantly less than optimal 
       
   184     for some filters on some platforms.
       
   185     
       
   186     Returns true if the operation can be initiated; otherwise returns false.
       
   187     
       
   188     Note: This function should not initiate network activity, instead only message data
       
   189     already stored on the device will be used during evaluation of the function.
       
   190     
       
   191     \sa  QMessage, QMessageFilter, messagesCounted(), progressChanged(), queryMessages()
       
   192 */
       
   193 
       
   194 /*!
       
   195     \fn QMessageService::send(QMessage &message)
       
   196   
       
   197     Transmit \a message using the account identified by the message's \l{QMessage::parentAccountId()}{parentAccountId} function.
       
   198     If the message does not have a valid parentAccountId, it will be set to the 
       
   199     result of QMessageAccount::defaultAccount() for the message's \l{QMessage::Type}{type}.
       
   200     
       
   201     The message will be stored in the standard Outbox folder for the account before
       
   202     transmission, or moved to that folder if it is already stored in another folder.
       
   203     If transmission is successful, the message will be moved to the standard Sent
       
   204     folder for the account.
       
   205     
       
   206     Currently on the Maemo 5 (Fremantle) and Windows Mobile platforms the service 
       
   207     action object enters the FinishedState when the message is queued for sending 
       
   208     rather than actually sent.
       
   209   
       
   210     Returns true if the operation can be initiated; otherwise returns false.
       
   211     
       
   212     \sa QMessage, QMessageAccountId
       
   213 */
       
   214 
       
   215 /*!
       
   216     \fn QMessageService::compose(const QMessage &message)
       
   217   
       
   218     Open a composer application using \a message as a prototype.
       
   219   
       
   220     The default application for handling the type of \a message should be used.
       
   221   
       
   222     Returns true if the operation can be initiated; otherwise returns false.
       
   223     
       
   224     On the QMF platform implementation of this function is left as a task for system 
       
   225     integrators.
       
   226     
       
   227     \sa QMessage::type()
       
   228 */
       
   229 
       
   230 /*!
       
   231     \fn QMessageService::retrieveHeader(const QMessageId& id)
       
   232   
       
   233     Retrieve meta data of the message identified by \a id.  
       
   234 
       
   235     The meta data (including flags, from, to, subject, and date fields where applicable) of 
       
   236     the message identified by \a id should be retrieved.  If only the message envelope
       
   237     information is present, any other accessible header information should be retrieved.
       
   238     
       
   239     If the message can not be found on the originating server it will be marked as removed.
       
   240 
       
   241     Returns true if the operation can be initiated; otherwise returns false.
       
   242     
       
   243     \sa QMessageId, QMessage::Removed
       
   244 */
       
   245 
       
   246 /*!
       
   247     \fn QMessageService::retrieveBody(const QMessageId& id)
       
   248   
       
   249     Retrieve the body of the message identified by \a id.  
       
   250 
       
   251     If the message can not be found on the originating server it will be marked as removed.
       
   252 
       
   253     On the Symbian^3 platform this function is not yet supported.
       
   254 
       
   255     Returns true if the operation can be initiated; otherwise returns false.
       
   256     
       
   257     \sa QMessageId, QMessage::Removed
       
   258 */
       
   259 
       
   260 /*!
       
   261     \fn QMessageService::retrieve(const QMessageId &messageId, const QMessageContentContainerId& id)
       
   262   
       
   263     Retrieve the container identified by \a messageId and \a id, the contents of the container should also be 
       
   264     retrieved.
       
   265     
       
   266     Returns true if the operation can be initiated; otherwise returns false.
       
   267     
       
   268     \sa QMessageContentContainerId
       
   269 */
       
   270 
       
   271 /*!
       
   272     \fn QMessageService::show(const QMessageId& id)
       
   273   
       
   274     Show the message identified by \a id.
       
   275 
       
   276     The default application for handling the type of message that \a id identifies should be used.
       
   277 
       
   278     Returns true if the operation can be initiated; otherwise returns false.
       
   279     
       
   280     On the Maemo 5 (Fremantle) platform this function is not yet supported for SMS type messages.
       
   281     
       
   282     On the QMF platform implementation of this function is left as a task for system 
       
   283     integrators.
       
   284     
       
   285     \sa QMessageId, QMessage::type()
       
   286 */
       
   287     
       
   288 /*!
       
   289     \fn QMessageService::exportUpdates(const QMessageAccountId &id)
       
   290   
       
   291     Initiate synchronization with external servers of local changes that have been queued by message store operations, 
       
   292     for messages with parent account \a id.
       
   293 
       
   294     On Windows mobile and desktop platforms this function performs no operation, as when a connection is available, 
       
   295     local changes are opportunistically synchronized with external servers.
       
   296 
       
   297     Returns true if the operation can be initiated; otherwise returns false.
       
   298     
       
   299     \sa QMessageManager::addMessage(), QMessageManager::updateMessage(), QMessageManager::removeMessage(), QMessageManager::removeMessages()
       
   300 */
       
   301     
       
   302 /*!
       
   303     \fn QMessageService::state() const
       
   304   
       
   305     Returns the current state of the operation.
       
   306 
       
   307     \sa stateChanged()
       
   308 */
       
   309 
       
   310 /*!
       
   311     \fn QMessageService::cancel()
       
   312   
       
   313     Attempts to cancel the last requested operation.
       
   314 */
       
   315 
       
   316 /*!
       
   317     \fn QMessageService::stateChanged(QMessageService::State newState)
       
   318 
       
   319     This signal is emitted when the state of the operation changes, with the new state described by \a newState.
       
   320 
       
   321     \sa state()
       
   322 */
       
   323 
       
   324 /*!
       
   325     \fn QMessageService::messagesFound(const QMessageIdList &ids);
       
   326 
       
   327     This signal is emitted when a queryMessages() operation has found
       
   328     messages.
       
   329 
       
   330     \a ids is the list of identifiers of messages found.
       
   331 
       
   332     \sa queryMessages()
       
   333 */
       
   334 
       
   335 /*!
       
   336     \fn QMessageService::messagesCounted(int count);
       
   337 
       
   338     This signal is emitted when a countMessages() operation has counted
       
   339     messages.
       
   340 
       
   341     \a count is the number of matching messages found.
       
   342 
       
   343     \sa queryMessages()
       
   344 */
       
   345 
       
   346 /*!
       
   347     \fn QMessageService::progressChanged(uint value, uint total)
       
   348 
       
   349     This signal is emitted when the operation operation has progressed.
       
   350 
       
   351     \a total is the total number of progress steps to perform, or zero if
       
   352     the number of progress steps is unknown.
       
   353 
       
   354     \a value is the number of progress steps completed so far.
       
   355 */
       
   356 
       
   357 /*!
       
   358     \fn QMessageService::error() const
       
   359   
       
   360     Returns a value indicating the last error condition encountered by the operation.
       
   361 */
       
   362 
       
   363 #include "moc_qmessageservice.cpp"
       
   364 QTM_END_NAMESPACE