|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 |
|
21 #include "MtfTestActionUtilsUser.h" |
|
22 #include "CMtfTestActionUtilsDeleteAllChildren.h" |
|
23 |
|
24 |
|
25 CMtfTestActionUtilsDeleteAllChildren::CMtfTestActionUtilsDeleteAllChildren(CMsvSession* aSession,TMsvId aParentId) |
|
26 : CActive(EPriorityNormal), iSession(aSession), iParentId(aParentId) |
|
27 { |
|
28 CActiveScheduler::Add(this); |
|
29 } |
|
30 |
|
31 |
|
32 CMtfTestActionUtilsDeleteAllChildren::~CMtfTestActionUtilsDeleteAllChildren() |
|
33 { |
|
34 delete iEntry; |
|
35 delete iSelection; |
|
36 } |
|
37 |
|
38 |
|
39 void CMtfTestActionUtilsDeleteAllChildren::StartL(TRequestStatus& aStatus) |
|
40 { |
|
41 iRequestStatus = &aStatus; |
|
42 aStatus = KRequestPending; |
|
43 |
|
44 iEntry = CMsvEntry::NewL(*iSession,iParentId,TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue)); |
|
45 iEntry->SetEntryL(iParentId); |
|
46 iSelection = iEntry->ChildrenL(); |
|
47 iTotalChildren = iSelection->Count(); |
|
48 if (iTotalChildren == 0) |
|
49 User::RequestComplete(iRequestStatus,KErrNone); |
|
50 else |
|
51 { |
|
52 iOperation = iEntry->DeleteL((*iSelection)[iCurrentChild],iStatus); |
|
53 SetActive(); |
|
54 iState = EStateThisLevel; |
|
55 } |
|
56 } |
|
57 |
|
58 |
|
59 void CMtfTestActionUtilsDeleteAllChildren::DoCancel() |
|
60 { |
|
61 switch (iState) |
|
62 { |
|
63 case EStateThisLevel: |
|
64 iOperation->Cancel(); |
|
65 break; |
|
66 |
|
67 case EStateNextLevel: |
|
68 iNextLevel->Cancel(); |
|
69 break; |
|
70 } |
|
71 } |
|
72 |
|
73 |
|
74 void CMtfTestActionUtilsDeleteAllChildren::RunL() |
|
75 { |
|
76 TInt err; |
|
77 |
|
78 switch (iState) |
|
79 { |
|
80 case EStateThisLevel: |
|
81 err = MtfTestActionUtilsUser::FinalProgressStatus(*iOperation,iStatus); |
|
82 |
|
83 delete iOperation; |
|
84 iOperation = NULL; |
|
85 |
|
86 switch (err) |
|
87 { |
|
88 case KErrAccessDenied: |
|
89 iUndeletedChildren++; |
|
90 iNextLevel = new (ELeave) CMtfTestActionUtilsDeleteAllChildren(iSession,(*iSelection)[iCurrentChild]); |
|
91 iNextLevel->StartL(iStatus); |
|
92 SetActive(); |
|
93 iState = EStateNextLevel; |
|
94 break; |
|
95 |
|
96 case KErrNone: |
|
97 if (++iCurrentChild == iTotalChildren) |
|
98 User::RequestComplete(iRequestStatus,KErrNone); |
|
99 else |
|
100 { |
|
101 iOperation = iEntry->DeleteL((*iSelection)[iCurrentChild],iStatus); |
|
102 SetActive(); |
|
103 } |
|
104 break; |
|
105 |
|
106 default: |
|
107 User::RequestComplete(iRequestStatus,err); |
|
108 break; |
|
109 } |
|
110 break; |
|
111 |
|
112 case EStateNextLevel: |
|
113 err = iStatus.Int(); |
|
114 |
|
115 iUndeletedChildren += iNextLevel->Undeleted(); |
|
116 delete iNextLevel; |
|
117 iNextLevel = NULL; |
|
118 |
|
119 switch (err) |
|
120 { |
|
121 case KErrNone: |
|
122 if (++iCurrentChild == iTotalChildren) |
|
123 User::RequestComplete(iRequestStatus,KErrNone); |
|
124 else |
|
125 { |
|
126 iOperation = iEntry->DeleteL((*iSelection)[iCurrentChild],iStatus); |
|
127 SetActive(); |
|
128 iState = EStateThisLevel; |
|
129 } |
|
130 break; |
|
131 |
|
132 default: |
|
133 User::RequestComplete(iRequestStatus,err); |
|
134 break; |
|
135 } |
|
136 break; |
|
137 } |
|
138 } |
|
139 |