|
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 "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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation for a global list message query client API. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "AknGlobalListMsgQuery.h" |
|
19 #include <bamdesca.h> // MDesCArray |
|
20 #include <AknNotifyStd.h> |
|
21 #include <AknPanic.h> |
|
22 #include <s32mem.h> |
|
23 #include <AknNotifySignature.h> |
|
24 #include <aknSDData.h> |
|
25 |
|
26 const TInt KBufferGranularity = 128; |
|
27 |
|
28 EXPORT_C CAknGlobalListMsgQuery* CAknGlobalListMsgQuery::NewL() |
|
29 { |
|
30 CAknGlobalListMsgQuery* self = NewLC(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 EXPORT_C CAknGlobalListMsgQuery* CAknGlobalListMsgQuery::NewLC() |
|
36 { |
|
37 CAknGlobalListMsgQuery* self = new(ELeave) CAknGlobalListMsgQuery; |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 EXPORT_C CAknGlobalListMsgQuery::~CAknGlobalListMsgQuery() |
|
44 { |
|
45 iNotify.Close(); |
|
46 delete iBuffer; |
|
47 delete iHeading; |
|
48 delete iAknSDData; |
|
49 } |
|
50 |
|
51 EXPORT_C void CAknGlobalListMsgQuery::ShowListMsgQueryL( |
|
52 const MDesCArray* aItems, |
|
53 TRequestStatus& aStatus, |
|
54 const TDesC& aHeaderText, |
|
55 const TDesC& aMsgText, |
|
56 const TInt aIndex, |
|
57 TInt aSoftKeys, |
|
58 TInt aAcceptKeyId, |
|
59 TInt aCancelKeyId, |
|
60 const TDesC& aHeaderImageFile, |
|
61 TInt aImageId, |
|
62 TInt aImageMaskId, |
|
63 CAknQueryDialog::TTone aTone) |
|
64 { |
|
65 iIndex = aIndex; |
|
66 const TInt count = aItems->MdcaCount(); |
|
67 |
|
68 SetHeadingL(aHeaderText); |
|
69 |
|
70 delete iBuffer; |
|
71 iBuffer = NULL; |
|
72 iBuffer = CBufFlat::NewL(KBufferGranularity); |
|
73 |
|
74 RBufWriteStream bufStream; |
|
75 bufStream.Open(*iBuffer); |
|
76 |
|
77 CleanupClosePushL(bufStream); |
|
78 |
|
79 bufStream.WriteInt32L(KAKNNOTIFIERSIGNATURE); |
|
80 bufStream.WriteInt16L(aIndex); |
|
81 |
|
82 bufStream.WriteInt16L(count); |
|
83 for (TInt ii = 0; ii < count; ii++) |
|
84 { |
|
85 bufStream << (aItems->MdcaPoint(ii)); |
|
86 } |
|
87 |
|
88 if (iHeading) |
|
89 { |
|
90 bufStream.WriteInt16L(iHeading->Length()); |
|
91 bufStream << (*iHeading); |
|
92 } |
|
93 else // heading is optional |
|
94 { |
|
95 bufStream.WriteInt16L(KErrNotFound); |
|
96 } |
|
97 |
|
98 // Enable listbox to have message under title. |
|
99 bufStream.WriteInt16L(aMsgText.Length()); |
|
100 bufStream << aMsgText; |
|
101 |
|
102 bufStream.WriteInt16L(aImageId); |
|
103 bufStream.WriteInt16L(aImageMaskId); |
|
104 bufStream.WriteInt16L(aTone); |
|
105 bufStream.WriteInt16L(aHeaderImageFile.Length()); |
|
106 if (aHeaderImageFile.Length()) |
|
107 { |
|
108 bufStream << aHeaderImageFile; |
|
109 } |
|
110 bufStream.WriteInt32L(iSkinsMajorId); |
|
111 bufStream.WriteInt32L(iSkinsMinorId); |
|
112 bufStream.WriteInt32L(aSoftKeys); |
|
113 bufStream.WriteInt32L(aAcceptKeyId); |
|
114 bufStream.WriteInt32L(aCancelKeyId); |
|
115 |
|
116 if (iAknSDData) |
|
117 { |
|
118 bufStream.WriteInt8L(ETrue); |
|
119 bufStream << *iAknSDData; |
|
120 } |
|
121 else |
|
122 { |
|
123 bufStream.WriteInt8L(EFalse); |
|
124 } |
|
125 |
|
126 iBufferPtr.Set(iBuffer->Ptr(0)); |
|
127 |
|
128 iNotify.StartNotifierAndGetResponse( |
|
129 aStatus, |
|
130 KAknGlobalListMsgQueryUid, |
|
131 iBufferPtr, |
|
132 iResultBuf); |
|
133 |
|
134 CleanupStack::PopAndDestroy(&bufStream); |
|
135 } |
|
136 |
|
137 /** |
|
138 * Move selection up |
|
139 */ |
|
140 EXPORT_C void CAknGlobalListMsgQuery::MoveSelectionUp() |
|
141 { |
|
142 iCmd = EAknMoveUpGlobalListQuery; |
|
143 UpdateListMsgQuery(); |
|
144 } |
|
145 |
|
146 /** |
|
147 * Move selection down |
|
148 */ |
|
149 EXPORT_C void CAknGlobalListMsgQuery::MoveSelectionDown() |
|
150 { |
|
151 iCmd = EAknMoveDownGlobalListQuery; |
|
152 UpdateListMsgQuery(); |
|
153 } |
|
154 |
|
155 /** |
|
156 * Select currently selected item in the list |
|
157 */ |
|
158 EXPORT_C void CAknGlobalListMsgQuery::SelectItem() |
|
159 { |
|
160 iCmd = EAknSelectGlobalListQuery; |
|
161 UpdateListMsgQuery(); |
|
162 } |
|
163 |
|
164 /** |
|
165 * Cancel the query |
|
166 */ |
|
167 EXPORT_C void CAknGlobalListMsgQuery::CancelListMsgQuery() |
|
168 { |
|
169 if (iBuffer) |
|
170 { |
|
171 iNotify.CancelNotifier(KAknGlobalListMsgQueryUid); |
|
172 delete iBuffer; |
|
173 iBuffer = 0; |
|
174 } |
|
175 } |
|
176 |
|
177 void CAknGlobalListMsgQuery::UpdateListMsgQuery() |
|
178 { |
|
179 TPckgBuf<SAknNotifierPackage<SAknGlobalListQueryParams> > pckg; |
|
180 pckg().iParamData.iCmd = iCmd; |
|
181 TPckgBuf<TInt> ret; |
|
182 iNotify.UpdateNotifier(KAknGlobalListMsgQueryUid, pckg, ret); |
|
183 } |
|
184 |
|
185 void CAknGlobalListMsgQuery::SetHeadingL(const TDesC& aHeading) |
|
186 { |
|
187 delete iHeading; |
|
188 iHeading = 0; |
|
189 iHeading = aHeading.AllocL(); |
|
190 } |
|
191 |
|
192 CAknGlobalListMsgQuery::CAknGlobalListMsgQuery() |
|
193 { |
|
194 } |
|
195 |
|
196 void CAknGlobalListMsgQuery::ConstructL() |
|
197 { |
|
198 User::LeaveIfError(iNotify.Connect()); |
|
199 } |
|
200 |
|
201 EXPORT_C void CAknGlobalListMsgQuery::SetSecondaryDisplayData(CAknSDData* aData) |
|
202 { |
|
203 delete iAknSDData; |
|
204 iAknSDData = aData; |
|
205 } |
|
206 |
|
207 EXPORT_C void CAknGlobalListMsgQuery::SetImageSkinId(const TAknsItemID& aId) |
|
208 { |
|
209 iSkinsMajorId = aId.iMajor; |
|
210 iSkinsMinorId = aId.iMinor; |
|
211 } |
|
212 |
|
213 // End of File |