/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example writemessage
    \title 'Write Message' Example



    This example demonstrates using the QtMobility Messaging API to
    create and send a simple message.

    \image writemessage-example.png

    The writemessage application provides an interface allowing the user to
    compose a simple message and send that message to one or more
    recipients.  The type of message that is sent will depend on the
    messaging account that the user selects for transmission.

    In order to know what type of message to create, our application
    requires that the user select an account to transmit with.  We create
    a listing to present the user a choice, by populating a combo box
    with the names of the available accounts:

    \snippet    ../../examples/writemessage/messagesender.cpp accounts-listing

    We create a mapping of the account name to the most capable type of message
    that can be transmitted via that account.  When an account is selected,
    we will adjust our UI to disable the message elements that cannot be
    transmitted using the associated message type.  For example, an SMS
    message cannot transmit attachments or a subject line.

    \snippet    ../../examples/writemessage/messagesender.cpp account-selected

    When the user presses the Send button, we create a message that contains
    the information they have provided.  First of all, we create a message
    object to transmit, and associate it with the account and message type
    that correspond to the user's account selection:

    \snippet    ../../examples/writemessage/messagesender.cpp associate-account

    Next, we process the recipient address or addresses that were provided.
    For each whitespace-separated element, we create an address object that
    has that element as the recipient, with the address type determined by
    the type of message we are constructing.

    \snippet    ../../examples/writemessage/messagesender.cpp set-recipients

    Next, we set the subject of the message (if the message can contain a subject)
    and set the text of the message.

    \snippet    ../../examples/writemessage/messagesender.cpp set-properties

    If the message can contain attachments, we add them as a list of file paths
    to be appended to the message:

    \snippet    ../../examples/writemessage/messagesender.cpp add-attachments

    Now that we have created our message, we use the QMessageService::send()
    operation to request that the message be stored in the system and transmitted:

    \snippet    ../../examples/writemessage/messagesender.cpp send-message

    To determine whether our transmission is successful, we wait for changes
    to the \l{QMessageService::state()}{state} of the QMessageService object.
    When the state changes to the FinishedState, we need to check whether
    the request was successful or not:

    \snippet    ../../examples/writemessage/messagesender.cpp handle-response

*/

