epoc32/include/mw/akngloballistmsgquery.h
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 akngloballistmsgquery.h
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Uses notification framework to show a global list query with 
       
    15 *                message field.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef __AKNGLOBALLISTMSGQUERY_H__
       
    20 #define __AKNGLOBALLISTMSGQUERY_H__
       
    21 
       
    22 #include <aknnotifystd.h>
       
    23 #include <aknquerydialog.h>
       
    24 
       
    25 class CAknSDData;
       
    26 
       
    27 /**
       
    28 * Uses notification framework to show a global list query with message field.
       
    29 *   
       
    30 * Usage:
       
    31 *     Create an active object, start it and pass its TRequestStatus as a
       
    32 *     parameter to ShowListMsgQueryL(). After the user selects one item from
       
    33 *     the query and accepts it, the request status will hold the number of the
       
    34 *     selected item. If the user cancels the query with softkey, the request status will
       
    35 *     hold -1. If method CancelListMsgQuery() is called, the request status will  
       
    36 *     hold -3 (KErrCancel).
       
    37 *
       
    38 * Example 1. Show the global list message query:
       
    39 * @code
       
    40 *     #include <akngloballistmsgquery.h>
       
    41 *     ...
       
    42 *     _LIT(KQueryHeaderText, "Global list msg query");
       
    43 *     _LIT(KQueryMsgText, "Query message.");
       
    44 *     _LIT(KListMsgQueryItem1, "Item 1");
       
    45 *     _LIT(KListMsgQueryItem2, "Item 2");
       
    46 *
       
    47 *     CDesCArray* textArray = new (ELeave) CDesCArrayFlat(2);
       
    48 *     CleanupStack::PushL(textArray);
       
    49 *     textArray->AppendL(KListMsgQueryItem1);
       
    50 *     textArray->AppendL(KListMsgQueryItem2);
       
    51 *         
       
    52 *     if (iListObserver)
       
    53 *         {
       
    54 *         iListObserver->Cancel();
       
    55 *         delete iListObserver;
       
    56 *         iListObserver = 0;
       
    57 *         }
       
    58 *
       
    59 *     if (iGlobalListMsgQuery)
       
    60 *         {
       
    61 *         delete iGlobalListMsgQuery;
       
    62 *         iGlobalListMsgQuery = 0;
       
    63 *         }
       
    64 *
       
    65 *     iListObserver = CMyActiveObject::NewL();
       
    66 *     iGlobalListMsgQuery = CAknGlobalListMsgQuery::NewL();
       
    67 *
       
    68 *     iGlobalListMsgQuery->ShowListMsgQueryL(
       
    69 *         textArray, 
       
    70 *         iListObserver->iStatus, 
       
    71 *         KQueryHeaderText,
       
    72 *         KQueryMsgText);
       
    73 *
       
    74 *     iListObserver->Start();
       
    75 *
       
    76 *     CleanupStack::PopAndDestroy(textArray);
       
    77 * @endcode
       
    78 *
       
    79 * Example 2. Get and handle the result in active object. The result is simply displayed on 
       
    80 *            screen using info message:
       
    81 * @code
       
    82 *     void CMyActiveObject::RunL() 
       
    83 *         {
       
    84 *         _LIT(KReceivedMsg, "Received:");
       
    85 *         TBuf<100> msg = KReceivedMsg();
       
    86 *         msg.AppendNum(iStatus.Int());
       
    87 *         CEikonEnv::Static()->InfoMsg(msg);
       
    88 *         }
       
    89 * @endcode
       
    90 *
       
    91 * @lib AknNotify.lib
       
    92 * @since S60 3.2
       
    93 */
       
    94 NONSHARABLE_CLASS(CAknGlobalListMsgQuery) : public CBase
       
    95     {
       
    96 public:
       
    97     /**
       
    98     * Two-phased constructor.
       
    99     *
       
   100     * @return A pointer to the new instance.
       
   101     */
       
   102     IMPORT_C static CAknGlobalListMsgQuery* NewL();
       
   103 
       
   104     /**
       
   105     * Two-phased constructor. Leaves the instance to cleanup stack.
       
   106     *
       
   107     * @return A pointer to the new instance.
       
   108     */
       
   109     IMPORT_C static CAknGlobalListMsgQuery* NewLC();
       
   110 
       
   111     /**
       
   112     * Destructor.
       
   113     */
       
   114     IMPORT_C ~CAknGlobalListMsgQuery();
       
   115 
       
   116     /**
       
   117     * Shows the global list message query.
       
   118     *
       
   119     * @param  aItems           Array of strings for list items. The items will be copied, so it is
       
   120     *                          safe to delete the array as soon as ShowListMsgQueryL() has been called.
       
   121     * @param  aStatus          TRequestStatus which will be completed when user dismisses the query.
       
   122     *                          Will contain KErrInUse if another global list query is already being shown.
       
   123     *                          Will contain KErrArgument if aSoftkeys does not point to a valid resource.
       
   124     *                          Will contain KErrArgument if aItems array is empty.
       
   125     *                          Will contain KErrArgument if aIndex is out of bounds.
       
   126     *                          Will contain KErrArgument if aAcceptKeyId is EAknSoftkeyCancel.
       
   127     *                          Will contain KErrArgument if aCancelKeyId is EAknSoftkeyOk.
       
   128     * @param  aHeaderText      Query header text.
       
   129     * @param  aMsgText         Query message text. Maximum is three lines.
       
   130     * @param  aIndex           Index of the item that will be highlighted by default.    
       
   131     * @param  aSoftkeys        Softkey resource id from Avkon.rss. If used, give also 
       
   132     *                          aAcceptKeyId and aCancelKeyId.
       
   133     * @param  aAcceptKeyId     Identifier of the softkey that is used to accept the query.
       
   134     * @param  aCancelKeyId     Identifier of the softkey that is used to cancel the query.
       
   135     * @param  aHeaderImageFile A full path to image to be used in the header field.
       
   136     * @param  aImageId         Image id.
       
   137     * @param  aImageId         Image mask id.
       
   138     * @param  aTone            Tone id.
       
   139     */
       
   140     IMPORT_C void ShowListMsgQueryL(
       
   141         const MDesCArray* aItems,
       
   142         TRequestStatus& aStatus,
       
   143         const TDesC& aHeaderText,
       
   144         const TDesC& aMsgText,
       
   145         const TInt aIndex = 0,
       
   146         TInt aSoftkeys = 0,
       
   147         TInt aAcceptKeyId = 0,
       
   148         TInt aCancelKeyId = 0,
       
   149         const TDesC& aHeaderImageFile = KNullDesC,        
       
   150         TInt aImageId = 0,
       
   151         TInt aImageMaskId = -1,
       
   152         CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone);
       
   153 
       
   154     /**
       
   155     * Moves selection up.
       
   156     */
       
   157     IMPORT_C void MoveSelectionUp();
       
   158 
       
   159     /**
       
   160     * Moves selection down.
       
   161     */
       
   162     IMPORT_C void MoveSelectionDown();
       
   163 
       
   164     /**
       
   165     * Selects currently selected item in the list.
       
   166     */
       
   167     IMPORT_C void SelectItem();
       
   168 
       
   169     /**
       
   170     * Cancels the query.
       
   171     */
       
   172     IMPORT_C void CancelListMsgQuery();
       
   173 
       
   174     /**
       
   175     * Sets additional information to be sent to secondary display. Takes ownership of object.
       
   176     * Must be called before sending data to notifier to have effect.
       
   177     *
       
   178     * @param aData Data to be sent to cover UI.
       
   179     */
       
   180     IMPORT_C void SetSecondaryDisplayData(CAknSDData* aData);
       
   181     
       
   182     /**
       
   183     * Sets skin id for image. Must be called before ShowListMsgQueryL() is called.
       
   184     * 
       
   185     * @param aId Image skin id.
       
   186     */
       
   187     IMPORT_C void SetImageSkinId(const TAknsItemID& aId);
       
   188     
       
   189 private:
       
   190     /**
       
   191     * Default constructor.
       
   192     */
       
   193     CAknGlobalListMsgQuery();
       
   194 
       
   195     /**
       
   196     * Symbian second-phase constructor.
       
   197     */
       
   198     void ConstructL(); 
       
   199     
       
   200     /**
       
   201     * Sets the heading for the query.
       
   202     */
       
   203     void SetHeadingL(const TDesC& aHeading);
       
   204     
       
   205     /**
       
   206     * Updates the query.
       
   207     */
       
   208     void UpdateListMsgQuery();        
       
   209 
       
   210 private:
       
   211     // Command id.
       
   212     TAknGlobalQueryCmd iCmd;
       
   213     // Notifier handle.
       
   214     RNotifier iNotify;
       
   215     // Index to set which item will be selected.
       
   216     TInt iIndex;
       
   217     // Buffer to hold the variables passed to server.
       
   218     CBufFlat *iBuffer;
       
   219     // Pointer to buffer.
       
   220     TPtrC8 iBufferPtr;
       
   221     HBufC* iHeading;
       
   222     CAknSDData* iAknSDData;
       
   223     TBuf8<1> iResultBuf; // Not really used, but needed to prevent buffer handling errors.
       
   224     TInt iSkinsMajorId;
       
   225     TInt iSkinsMinorId;
       
   226     };
       
   227 
       
   228 #endif // __AKNGLOBALLISTMSGQUERY_H__