|
1 /* |
|
2 * Copyright (c) 2005-2009 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 the License "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 /** |
|
19 @test |
|
20 @internalComponent |
|
21 |
|
22 This contains CT_FileManData |
|
23 */ |
|
24 |
|
25 #if (!defined __T_FILEMAN_DATA_H__) |
|
26 #define __T_FILEMAN_DATA_H__ |
|
27 |
|
28 // User Includes |
|
29 #include "DataWrapperBase.h" |
|
30 #include "FileserverUtil.h" |
|
31 |
|
32 // EPOC includes |
|
33 #include <e32std.h> |
|
34 #include <f32file.h> |
|
35 #include <f32fsys.h> |
|
36 |
|
37 struct THistoryData |
|
38 { |
|
39 TFileName iCurrentSource; |
|
40 TFileName iCurrentTarget; |
|
41 TEntry iCurrentEntry; |
|
42 TInt iBytesTransferred; |
|
43 CFileMan::TAction iCurrentAction; |
|
44 TFileManError iMoreInfoAboutError; |
|
45 TInt iLastError; |
|
46 TPtrC iFullPath; |
|
47 TPtrC iAbbreviatedPath; |
|
48 }; |
|
49 enum TObserverNotifyType |
|
50 { |
|
51 ENotifyStarted, |
|
52 ENotifyOperation, |
|
53 ENotifyEnded, |
|
54 ENotifyUnknown |
|
55 }; |
|
56 |
|
57 class CT_FileManData: public CDataWrapperBase, public MFileManObserver |
|
58 { |
|
59 public: |
|
60 static CT_FileManData* NewL(); |
|
61 ~CT_FileManData(); |
|
62 |
|
63 virtual TBool DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex); |
|
64 virtual TAny* GetObject(); |
|
65 |
|
66 protected: |
|
67 CT_FileManData(); |
|
68 void ConstructL(); |
|
69 |
|
70 void RunL(CActive* aActive, TInt aIndex); |
|
71 void DoCancel(CActive* aActive, TInt aIndex); |
|
72 |
|
73 private: |
|
74 inline void DoCmdNewL(const TDesC& aSection); |
|
75 inline void DoCmdAttribsL(const TDesC& aSection, const TInt aAsyncErrorIndex); |
|
76 inline void DoCmdCopyL(const TDesC& aSection, const TInt aAsyncErrorIndex); |
|
77 inline void DoCmdDeleteL(const TDesC& aSection, const TInt aAsyncErrorIndex); |
|
78 inline void DoCmdMoveL(const TDesC& aSection, const TInt aAsyncErrorIndex); |
|
79 inline void DoCmdRenameL(const TDesC& aSection, const TInt aAsyncErrorIndex); |
|
80 inline void DoCmdRmDirL(const TDesC& aSection, const TInt aAsyncErrorIndex); |
|
81 inline void DoCmdSetObserver(); |
|
82 |
|
83 inline void DoCmdCurrentAction(const TDesC& aSection); |
|
84 inline void DoCmdGetCurrentTarget(const TDesC& aSection); |
|
85 inline void DoCmdGetCurrentSource(const TDesC& aSection); |
|
86 inline void DoCmdBytesTransferredByCopyStep(const TDesC& aSection); |
|
87 inline void DoCmdCurrentEntryL(const TDesC& aSection); |
|
88 inline void DoCmdAbbreviatedPath(const TDesC& aSection); |
|
89 inline void DoCmdFullPath(const TDesC& aSection); |
|
90 inline void DoCmdGetLastError(const TDesC& aSection); |
|
91 inline void DoCmdGetMoreInfoAboutError(const TDesC& aSection); |
|
92 inline void DoCleanup(); |
|
93 |
|
94 // MFileManObserver events |
|
95 inline TControl NotifyFileManStarted(); |
|
96 inline TControl NotifyFileManOperation(); |
|
97 inline TControl NotifyFileManEnded(); |
|
98 |
|
99 // Helper functions for MFileManObserver Testing |
|
100 void ReadTControl(const TDesC& aSection); |
|
101 TBool GetTControlFromConfig(const TDesC& aParameterName, const TDesC& aSection, TControl& aFlag); |
|
102 |
|
103 // Helper function |
|
104 TBool GetActionFromConfig(const TDesC& aParameterName, const TDesC& aSection, CFileMan::TAction& aAction); |
|
105 TBool GetFileManErrorFromConfig(const TDesC& aParameterName, const TDesC& aSection, TFileManError& aError); |
|
106 void ConvertFileManErrorToString(TFileManError& aError, TPtrC& aErrorStr); |
|
107 void ConvertActionToString(CFileMan::TAction aAction, TPtrC& aActionStr); |
|
108 TBool GetOperationFromConfig(const TDesC& aParameterName, const TDesC& aSection, TUint& aSwitch); |
|
109 void ClearHistory(); |
|
110 void CreateHistoryRecord(THistoryData& aRecord); |
|
111 TBool GetNotifyType(const TDesC& aParameterName, const TDesC& aSection, TObserverNotifyType& aType); |
|
112 RPointerArray<THistoryData>* GetHistoryDataByType(const TDesC& aSection); |
|
113 |
|
114 private: |
|
115 //** CFileMan class instance that is tested */ |
|
116 CFileMan* iFileMan; |
|
117 |
|
118 /** Sores aAsyncErrorIndex (Only For MFileObserver notifications). */ |
|
119 TInt iAsyncErrorIndex; |
|
120 |
|
121 /** Indicates if functions called asynchronouslly (Only For MFileObserver notifications). */ |
|
122 TBool iAsyncCall; |
|
123 |
|
124 /** MFileManObserver class instance */ |
|
125 MFileManObserver* iFileManObserver; |
|
126 |
|
127 /** The request status for disk space events */ |
|
128 RPointerArray<CActiveCallback> iAttribs; |
|
129 |
|
130 /** The request status for disk space events */ |
|
131 RPointerArray<CActiveCallback> iCopy; |
|
132 |
|
133 /** The request status for disk space events */ |
|
134 RPointerArray<CActiveCallback> iDelete; |
|
135 |
|
136 /** The request status for disk space events */ |
|
137 RPointerArray<CActiveCallback> iMove; |
|
138 |
|
139 /** The request status for disk space events */ |
|
140 RPointerArray<CActiveCallback> iRename; |
|
141 |
|
142 /** The request status for disk space events */ |
|
143 RPointerArray<CActiveCallback> iRmDir; |
|
144 |
|
145 /** Stores history for NotifyFileManStarted */ |
|
146 RPointerArray<THistoryData> iStartedHistory; |
|
147 |
|
148 /** Stores history for NotifyFileManOperation */ |
|
149 RPointerArray<THistoryData> iOperationHistory; |
|
150 |
|
151 /** Stores history for NotifyFileManEnded */ |
|
152 RPointerArray<THistoryData> iEndedHistory; |
|
153 |
|
154 /** Stores return value for MFileManObserver Notifications */ |
|
155 TControl iTControl; |
|
156 |
|
157 /** Stores source of filename for which return specified TControl value. */ |
|
158 TFileName iNotifyFileName; |
|
159 |
|
160 /** Stores name of Notify Function. */ |
|
161 TObserverNotifyType iObserverNotifyType; |
|
162 |
|
163 /** Idicates if we need to use specified TControl value in notifications. */ |
|
164 TBool iUseTControl; |
|
165 |
|
166 }; |
|
167 |
|
168 #endif /* __T_FILEMAN_DATA_H__ */ |