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