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