1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "DismountClient.h" |
|
19 |
|
20 CDismountClient::CDismountClient() : |
|
21 CActive(EPriorityStandard) // Standard priority |
|
22 { |
|
23 } |
|
24 |
|
25 CDismountClient* CDismountClient::NewLC(CStifLogger *aLog) |
|
26 { |
|
27 CDismountClient* self = new (ELeave) CDismountClient(); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(aLog); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CDismountClient* CDismountClient::NewL(CStifLogger *aLog) |
|
34 { |
|
35 CDismountClient* self = CDismountClient::NewLC(aLog); |
|
36 CleanupStack::Pop(); // self; |
|
37 return self; |
|
38 } |
|
39 |
|
40 void CDismountClient::ConstructL(CStifLogger *aLog) |
|
41 { |
|
42 User::LeaveIfError(iTimer.CreateLocal()); |
|
43 iLog = aLog; |
|
44 User::LeaveIfError( iFs.Connect() ); |
|
45 |
|
46 CActiveScheduler::Add(this); // Add to scheduler |
|
47 } |
|
48 |
|
49 CDismountClient::~CDismountClient() |
|
50 { |
|
51 Cancel(); // Cancel any request, if outstanding |
|
52 // Delete instance variables if any |
|
53 iTimer.Close(); |
|
54 iFs.NotifyDismountCancel(); |
|
55 iFs.Close(); |
|
56 } |
|
57 |
|
58 void CDismountClient::DoCancel() |
|
59 { |
|
60 iTimer.Cancel(); |
|
61 iFs.NotifyDismountCancel(); |
|
62 } |
|
63 |
|
64 void CDismountClient::StartL(TAllowDismountOption aAllowDismountOption) |
|
65 { |
|
66 Cancel(); |
|
67 |
|
68 iAllowDismountOption = aAllowDismountOption; |
|
69 if (iAllowDismountOption == EAllowDismountTooLate || |
|
70 iAllowDismountOption == EAllowDismountAfter2Sec) |
|
71 { |
|
72 iState = EDelay; |
|
73 } |
|
74 |
|
75 iFs.NotifyDismount(EDriveE,iStatus,EFsDismountRegisterClient); |
|
76 RDebug::Printf( " DiscmountClient StartL "); |
|
77 iFs.NotifyDismountCancel(); |
|
78 SetActive(); |
|
79 } |
|
80 |
|
81 void CDismountClient::RunL() |
|
82 { |
|
83 |
|
84 switch (iAllowDismountOption) |
|
85 { |
|
86 case EAllowDismount: |
|
87 iFs.AllowDismount(EDriveE); |
|
88 break; |
|
89 |
|
90 case EAllowDismountAfter2Sec: |
|
91 if (iState ==EDelay) |
|
92 { |
|
93 iTimer.After(iStatus,(TTimeIntervalMicroSeconds32)2000000); |
|
94 iState=EWaitForDelay; |
|
95 SetActive(); |
|
96 } |
|
97 else |
|
98 if(iState==EWaitForDelay) |
|
99 { |
|
100 iFs.AllowDismount(EDriveE); |
|
101 iState=EDelay; |
|
102 } |
|
103 break; |
|
104 |
|
105 case EAllowDismountTooLate: |
|
106 if (iState == EDelay) |
|
107 { |
|
108 iTimer.After(iStatus,(TTimeIntervalMicroSeconds32)8000000); |
|
109 iState=EWaitForDelay; |
|
110 SetActive(); |
|
111 } |
|
112 else |
|
113 if(iState==EWaitForDelay) |
|
114 { |
|
115 iFs.AllowDismount(EDriveE); |
|
116 iState=EDelay; |
|
117 } |
|
118 break; |
|
119 |
|
120 case ENotAllowDismount: |
|
121 default: |
|
122 break; |
|
123 } |
|
124 } |
|
125 |
|
126 TInt CDismountClient::RunError(TInt aError) |
|
127 { |
|
128 return aError; |
|
129 } |
|