2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Uses notification framework to show a global list query with
19 #ifndef __AKNGLOBALLISTMSGQUERY_H__
20 #define __AKNGLOBALLISTMSGQUERY_H__
22 #include <AknNotifyStd.h>
23 #include <AknQueryDialog.h>
28 * Uses notification framework to show a global list query with message field.
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).
38 * Example 1. Show the global list message query:
40 * #include <akngloballistmsgquery.h>
42 * _LIT(KQueryHeaderText, "Global list msg query");
43 * _LIT(KQueryMsgText, "Query message.");
44 * _LIT(KListMsgQueryItem1, "Item 1");
45 * _LIT(KListMsgQueryItem2, "Item 2");
47 * CDesCArray* textArray = new (ELeave) CDesCArrayFlat(2);
48 * CleanupStack::PushL(textArray);
49 * textArray->AppendL(KListMsgQueryItem1);
50 * textArray->AppendL(KListMsgQueryItem2);
54 * iListObserver->Cancel();
55 * delete iListObserver;
59 * if (iGlobalListMsgQuery)
61 * delete iGlobalListMsgQuery;
62 * iGlobalListMsgQuery = 0;
65 * iListObserver = CMyActiveObject::NewL();
66 * iGlobalListMsgQuery = CAknGlobalListMsgQuery::NewL();
68 * iGlobalListMsgQuery->ShowListMsgQueryL(
70 * iListObserver->iStatus,
74 * iListObserver->Start();
76 * CleanupStack::PopAndDestroy(textArray);
79 * Example 2. Get and handle the result in active object. The result is simply displayed on
80 * screen using info message:
82 * void CMyActiveObject::RunL()
84 * _LIT(KReceivedMsg, "Received:");
85 * TBuf<100> msg = KReceivedMsg();
86 * msg.AppendNum(iStatus.Int());
87 * CEikonEnv::Static()->InfoMsg(msg);
94 NONSHARABLE_CLASS(CAknGlobalListMsgQuery) : public CBase
98 * Two-phased constructor.
100 * @return A pointer to the new instance.
102 IMPORT_C static CAknGlobalListMsgQuery* NewL();
105 * Two-phased constructor. Leaves the instance to cleanup stack.
107 * @return A pointer to the new instance.
109 IMPORT_C static CAknGlobalListMsgQuery* NewLC();
114 IMPORT_C ~CAknGlobalListMsgQuery();
117 * Shows the global list message query.
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.
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,
147 TInt aAcceptKeyId = 0,
148 TInt aCancelKeyId = 0,
149 const TDesC& aHeaderImageFile = KNullDesC,
151 TInt aImageMaskId = -1,
152 CAknQueryDialog::TTone aTone = CAknQueryDialog::ENoTone);
155 * Moves selection up.
157 IMPORT_C void MoveSelectionUp();
160 * Moves selection down.
162 IMPORT_C void MoveSelectionDown();
165 * Selects currently selected item in the list.
167 IMPORT_C void SelectItem();
172 IMPORT_C void CancelListMsgQuery();
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.
178 * @param aData Data to be sent to cover UI.
180 IMPORT_C void SetSecondaryDisplayData(CAknSDData* aData);
183 * Sets skin id for image. Must be called before ShowListMsgQueryL() is called.
185 * @param aId Image skin id.
187 IMPORT_C void SetImageSkinId(const TAknsItemID& aId);
191 * Default constructor.
193 CAknGlobalListMsgQuery();
196 * Symbian second-phase constructor.
201 * Sets the heading for the query.
203 void SetHeadingL(const TDesC& aHeading);
208 void UpdateListMsgQuery();
212 TAknGlobalQueryCmd iCmd;
215 // Index to set which item will be selected.
217 // Buffer to hold the variables passed to server.
219 // Pointer to buffer.
222 CAknSDData* iAknSDData;
223 TBuf8<1> iResultBuf; // Not really used, but needed to prevent buffer handling errors.
228 #endif // __AKNGLOBALLISTMSGQUERY_H__