|
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 // __ACTION_INFO_BEGIN__ |
|
15 // [Action Name] |
|
16 // ChangeToExternalDrive |
|
17 // [Action Parameters] |
|
18 // CMsvSession& Session <input>: Reference to the session. |
|
19 // TInt Drive <output-completion>: External drive (between D: and Y:) that we have changed to. |
|
20 // [Action Description] |
|
21 // Changes the current location of the mail server index to reside on the first available external drive. |
|
22 // Does nothing if that drive is already the one being used. |
|
23 // If there are no removable drives available, the action leaves with KErrNotFound |
|
24 // [APIs Used] |
|
25 // CMsvSession::ChangeDriveL |
|
26 // __ACTION_INFO_END__ |
|
27 // |
|
28 // |
|
29 |
|
30 /** |
|
31 @file |
|
32 */ |
|
33 |
|
34 |
|
35 #include "CMtfTestActionChangeToExternalDrive.h" |
|
36 #include "CMtfTestCase.h" |
|
37 #include "CMtfTestActionParameters.h" |
|
38 |
|
39 #include "MSVAPI.H" |
|
40 |
|
41 |
|
42 CMtfTestAction* CMtfTestActionChangeToExternalDrive::NewL(CMtfTestCase& aTestCase,CMtfTestActionParameters* aActionParameters) |
|
43 { |
|
44 CMtfTestActionChangeToExternalDrive* self = new (ELeave) CMtfTestActionChangeToExternalDrive(aTestCase); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(aActionParameters); |
|
47 CleanupStack::Pop(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 CMtfTestActionChangeToExternalDrive::CMtfTestActionChangeToExternalDrive(CMtfTestCase& aTestCase) |
|
53 : CMtfTestAction(aTestCase) |
|
54 { |
|
55 } |
|
56 |
|
57 |
|
58 CMtfTestActionChangeToExternalDrive::~CMtfTestActionChangeToExternalDrive() |
|
59 { |
|
60 if(iOperation) |
|
61 delete iOperation; |
|
62 } |
|
63 |
|
64 void CMtfTestActionChangeToExternalDrive::ExecuteActionL() |
|
65 { |
|
66 TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionChangeToExternalDrive); |
|
67 CActiveScheduler::Add(this); |
|
68 |
|
69 TVolumeInfo info; |
|
70 TDriveUnit externalDrive; |
|
71 |
|
72 RFs fs; |
|
73 User::LeaveIfError(fs.Connect()); |
|
74 CleanupClosePushL(fs); |
|
75 // Try to find a removable drive |
|
76 for (externalDrive = EDriveD; externalDrive < EDriveZ; externalDrive = TInt(externalDrive) + 1) |
|
77 { |
|
78 if (fs.Volume(info, TInt(externalDrive)) == KErrNone) |
|
79 break; |
|
80 } |
|
81 TInt currentDrive = MessageServer::CurrentDriveL(fs); |
|
82 CleanupStack::PopAndDestroy(&fs); // fs |
|
83 |
|
84 if (externalDrive == EDriveZ) |
|
85 { |
|
86 // didn't find any removable drive to change to |
|
87 User::Leave(KErrNotFound); |
|
88 } |
|
89 |
|
90 CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0)); |
|
91 // only change if not already using a external drive |
|
92 if (currentDrive < TInt(EDriveD)) // no need to check for Z drive, the index can't live there |
|
93 { |
|
94 iOperation = paramSession->ChangeDriveL(TInt(externalDrive), iStatus); |
|
95 SetActive(); |
|
96 iDrive = TInt(externalDrive); |
|
97 } |
|
98 else |
|
99 { |
|
100 // nothing to do, but let RunL run to complete the action and return the drive ID |
|
101 SetActive(); |
|
102 TRequestStatus* status = &iStatus; |
|
103 User::RequestComplete(status,KErrNone); |
|
104 iDrive = currentDrive; |
|
105 } |
|
106 TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionChangeToExternalDrive); |
|
107 } |
|
108 |
|
109 |
|
110 void CMtfTestActionChangeToExternalDrive::DoCancel() |
|
111 { |
|
112 if (iOperation) |
|
113 iOperation->Cancel(); |
|
114 } |
|
115 |
|
116 |
|
117 void CMtfTestActionChangeToExternalDrive::RunL() |
|
118 { |
|
119 User::LeaveIfError(iStatus.Int()); |
|
120 |
|
121 if(iOperation) |
|
122 { |
|
123 // unpack the final progress |
|
124 TPckgBuf<TMsvIndexLoadProgress> progressPack; |
|
125 TMsvIndexLoadProgress progress; |
|
126 progressPack.Copy(iOperation->ProgressL()); |
|
127 progress = progressPack(); |
|
128 |
|
129 User::LeaveIfError(progress.iError); |
|
130 } |
|
131 |
|
132 StoreParameterL<TInt>(TestCase(), iDrive, ActionParameters().Parameter(1)); |
|
133 |
|
134 TestCase().ActionCompletedL(*this); |
|
135 } |
|
136 |