|
1 /* |
|
2 * Copyright (c) 2007-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: Delete folder command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <liwcommon.h> |
|
20 #include <e32base.h> |
|
21 #include <eikenv.h> |
|
22 #include <StringLoader.h> |
|
23 #include <aknnotedialog.h> |
|
24 #include <AknQueryDialog.h> |
|
25 #include <AknWaitDialog.h> |
|
26 |
|
27 #include "mmfoldercommanddelete.h" |
|
28 #include "mmdialogmanager.h" |
|
29 #include "mmactionrequest.h" |
|
30 #include "hnglobals.h" |
|
31 #include "hnliwutils.h" |
|
32 #include "menudebug.h" |
|
33 #include "hnutils.h" |
|
34 |
|
35 #include "hnmdbasekey.h" |
|
36 #include "hnmdkeyfactory.h" |
|
37 #include "menudebug.h" |
|
38 #include "hnconvutils.h" |
|
39 #include "hnservicehandler.h" |
|
40 #include "mmpluginsharedresources.h" |
|
41 |
|
42 #include <avkon.rsg> |
|
43 #include <matrixmenu.rsg> |
|
44 #include <mmfolderuiextplugin.rsg> |
|
45 |
|
46 |
|
47 _LIT8( KChildrenCount8, "children_count" ); |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS ============================= |
|
50 // --------------------------------------------------------------------------- |
|
51 // Symbian factory function. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CMmFolderCommandDelete* CMmFolderCommandDelete::NewL() |
|
55 { |
|
56 CMmFolderCommandDelete* self = new( ELeave ) CMmFolderCommandDelete(); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // Symbian second phase constructor. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CMmFolderCommandDelete::ConstructL() |
|
69 { |
|
70 BaseConstructL(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Destructor. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CMmFolderCommandDelete::~CMmFolderCommandDelete() |
|
78 { |
|
79 delete iServiceHandler; |
|
80 if( iWaitDialog ) |
|
81 { |
|
82 delete iWaitDialog; |
|
83 } |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // Default C++ constructor. |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CMmFolderCommandDelete::CMmFolderCommandDelete() |
|
91 { |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 TInt CMmFolderCommandDelete::HandleNotifyL( TInt /*aCmdId*/, |
|
99 TInt aEventId, |
|
100 CLiwGenericParamList& /* aEventParamList */, |
|
101 const CLiwGenericParamList& /*aInParamList*/ ) |
|
102 { |
|
103 if( aEventId != KLiwEventCanceled ) |
|
104 { |
|
105 StopWaitDialogL(); |
|
106 MMPERF(("CFolderUiExtPlugin::DeleteFolderCommandL - END")); |
|
107 } |
|
108 return KErrNone; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CMmFolderCommandDelete::ExecuteActionL( |
|
116 CLiwGenericParamList* aEventParamList ) |
|
117 { |
|
118 MMPERF(("CFolderUiExtPlugin::DeleteFolderCommandL - START")); |
|
119 TInt id = GetIntL( *aEventParamList, KIdAttrName8 ); |
|
120 TPtrC currentName = GetStringL( *aEventParamList, KName8 ); |
|
121 TInt32 childrenCount = GetIntL( *aEventParamList, KChildrenCount8 ); |
|
122 |
|
123 if( childrenCount == 0 ) |
|
124 { |
|
125 if( DeleteQueryL( currentName ) ) |
|
126 { |
|
127 DeleteItemFromMcsL( id, currentName ); |
|
128 |
|
129 CLiwGenericParamList* list = CLiwGenericParamList::NewLC(); |
|
130 TLiwGenericParam command( KHnRequest, TLiwVariant( KDisableActionsForItem ) ); |
|
131 TLiwGenericParam itemCustomId( |
|
132 KItemCustomId8, TLiwVariant( static_cast<TInt32>( id ) ) ); |
|
133 list->AppendL( itemCustomId ); |
|
134 list->AppendL( command ); |
|
135 iActionRequest->HandleRequestL( *list ); |
|
136 CleanupStack::PopAndDestroy( list ); |
|
137 } |
|
138 } |
|
139 else |
|
140 { |
|
141 DisplayErrorInfoL( currentName ); |
|
142 } |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CMmFolderCommandDelete::MoveFocusBeforeDeleteL() |
|
150 { |
|
151 CLiwGenericParamList* list = CLiwGenericParamList::NewLC(); |
|
152 TLiwGenericParam command( KHnRequest, TLiwVariant( KMoveFocusBeforeDelete ) ); |
|
153 |
|
154 list->AppendL( command ); |
|
155 |
|
156 iActionRequest->HandleRequestL( *list ); |
|
157 CleanupStack::PopAndDestroy( list ); |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CMmFolderCommandDelete::StartWaitDialogL( const TDesC& aLabel ) |
|
165 { |
|
166 if( iWaitDialog ) |
|
167 { |
|
168 delete iWaitDialog; |
|
169 iWaitDialog = NULL; |
|
170 } |
|
171 |
|
172 // For the wait dialog |
|
173 iWaitDialog = new (ELeave) CAknWaitDialog( |
|
174 REINTERPRET_CAST( CEikDialog**, &iWaitDialog ) ); |
|
175 iWaitDialog->SetCallback( this ); |
|
176 iWaitDialog->SetTextL( aLabel ); |
|
177 iWaitDialog->ExecuteLD( R_MENU_WAIT_DIALOG ); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void CMmFolderCommandDelete::DialogDismissedL(TInt /*aButtonId*/) |
|
185 { |
|
186 // No implementation required. |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CMmFolderCommandDelete::StopWaitDialogL() |
|
194 { |
|
195 if( iWaitDialog ) |
|
196 { |
|
197 iWaitDialog->ProcessFinishedL(); |
|
198 } |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 TBool CMmFolderCommandDelete::DeleteQueryL( const TDesC& aFolderName ) |
|
206 { |
|
207 HBufC* msg = StringLoader::LoadLC( |
|
208 R_MENU_EDIT_DELETE_QUERY_TEXT, aFolderName ); |
|
209 CAknQueryDialog* dialog = CAknQueryDialog::NewL(); |
|
210 SetDialogL( dialog ); |
|
211 TBool result( dialog->ExecuteLD( R_MENU_EDIT_DELETE_QUERY, *msg ) ); |
|
212 SetDialogL( NULL ); |
|
213 CleanupStack::PopAndDestroy( msg ); |
|
214 return result; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CMmFolderCommandDelete::DeleteItemFromMcsL( |
|
222 TInt aId, const TDesC& aFolderName ) |
|
223 { |
|
224 MMPERF(("\t\t Delete folder - START")); |
|
225 |
|
226 GetListL( aId ); |
|
227 TInt pos( 0 ); |
|
228 TInt count( 0 ); |
|
229 const TLiwGenericParam* res = |
|
230 iGetListOutParam->FindFirst( pos, KReturnValue8() ); |
|
231 if( pos != KErrNotFound && res ) |
|
232 { |
|
233 count = res->Value().AsList()->Count(); |
|
234 } |
|
235 |
|
236 if( count == 0 ) |
|
237 { |
|
238 StartWaitDialogL( iSharedResources->GetMsgFolderDeleting() ); |
|
239 CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL( |
|
240 KInData8, KKeyTypeMap, KDefaultParentId8 ); |
|
241 CleanupStack::PushL( inDataKey ); |
|
242 |
|
243 HBufC8* id = HnConvUtils::NumToStr8LC( aId ); |
|
244 AddSubKeyL( inDataKey, KIdParam, KKeyTypeInteger, *id ); |
|
245 MCSQueryExecutionL( KCmdDelete8, inDataKey, NULL, this ); |
|
246 |
|
247 CleanupStack::PopAndDestroy( id ); |
|
248 CleanupStack::PopAndDestroy( inDataKey ); |
|
249 } |
|
250 else |
|
251 { |
|
252 HBufC* message = StringLoader::LoadLC( |
|
253 R_FLDR_CANNOT_DELETE_ITEM, aFolderName ); |
|
254 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
255 CAknNoteDialog::EConfirmationTone, |
|
256 CAknNoteDialog::ELongTimeout ); |
|
257 dialog->SetTextL( message->Des() ); |
|
258 dialog->ExecuteDlgLD( R_MENU_EDIT_MOVING_ABORT_NOTIFICATION ); |
|
259 |
|
260 CleanupStack::PopAndDestroy( message ); |
|
261 } |
|
262 |
|
263 MMPERF(("\t\t Delete folder - END")); |
|
264 } |
|
265 |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 // --------------------------------------------------------------------------- |
|
270 // |
|
271 void CMmFolderCommandDelete::UninstallL( TInt aId ) |
|
272 { |
|
273 MMPERF(("\t\t Delete folder - START")); |
|
274 |
|
275 CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL( |
|
276 KInData8, KKeyTypeMap, KDefaultParentId8 ); |
|
277 CleanupStack::PushL( inDataKey ); |
|
278 |
|
279 HBufC8* id = HnConvUtils::NumToStr8LC( aId ); |
|
280 AddSubKeyL( inDataKey, KIdParam, KKeyTypeInteger, *id ); |
|
281 AddSubKeyL( inDataKey, KAction, KKeyTypeString8, KActionRemove ); |
|
282 MCSQueryExecutionL( KCmdExecuteAction8, inDataKey, NULL, this ); |
|
283 |
|
284 CleanupStack::PopAndDestroy( id ); |
|
285 CleanupStack::PopAndDestroy( inDataKey ); |
|
286 |
|
287 MMPERF(("\t\t Delete folder - END")); |
|
288 } |
|
289 |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // Symbian factory function. |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 CMmFolderDeleteSuite* CMmFolderDeleteSuite::NewL() |
|
296 { |
|
297 CMmFolderDeleteSuite* self = new( ELeave ) CMmFolderDeleteSuite(); |
|
298 CleanupStack::PushL( self ); |
|
299 self->ConstructL(); |
|
300 CleanupStack::Pop( self ); |
|
301 return self; |
|
302 } |
|
303 |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // Symbian second phase constructor. |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CMmFolderDeleteSuite::ConstructL() |
|
310 { |
|
311 } |
|
312 |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // Destructor. |
|
316 // --------------------------------------------------------------------------- |
|
317 // |
|
318 CMmFolderDeleteSuite::~CMmFolderDeleteSuite() |
|
319 { |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // Default C++ constructor. |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 CMmFolderDeleteSuite::CMmFolderDeleteSuite() |
|
327 { |
|
328 } |
|
329 |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 // --------------------------------------------------------------------------- |
|
333 // |
|
334 void CMmFolderDeleteSuite::ExecuteActionL( |
|
335 CLiwGenericParamList* /* aEventParamList */ ) |
|
336 { |
|
337 // TPtrC currentName = GetStringL( *aEventParamList, KName8 ); |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // Symbian factory function. |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 CMmFolderDeleteApp* CMmFolderDeleteApp::NewL() |
|
345 { |
|
346 CMmFolderDeleteApp* self = new( ELeave ) CMmFolderDeleteApp(); |
|
347 CleanupStack::PushL( self ); |
|
348 self->ConstructL(); |
|
349 CleanupStack::Pop( self ); |
|
350 return self; |
|
351 } |
|
352 |
|
353 |
|
354 // --------------------------------------------------------------------------- |
|
355 // Symbian second phase constructor. |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 void CMmFolderDeleteApp::ConstructL() |
|
359 { |
|
360 |
|
361 } |
|
362 |
|
363 |
|
364 // --------------------------------------------------------------------------- |
|
365 // Destructor. |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 CMmFolderDeleteApp::~CMmFolderDeleteApp() |
|
369 { |
|
370 |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------------------------- |
|
374 // Default C++ constructor. |
|
375 // --------------------------------------------------------------------------- |
|
376 // |
|
377 CMmFolderDeleteApp::CMmFolderDeleteApp() |
|
378 { |
|
379 |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 // --------------------------------------------------------------------------- |
|
385 // |
|
386 void CMmFolderDeleteApp::ExecuteActionL( |
|
387 CLiwGenericParamList* aEventParamList ) |
|
388 { |
|
389 MMPERF(("CMmFolderDeleteApp::DeleteAppCommandL - START")); |
|
390 TInt id = GetIntL( *aEventParamList, KIdAttrName8 ); |
|
391 UninstallL( id ); |
|
392 } |
|
393 |
|
394 // end of file |
|
395 |