|
1 // KernLbxModel.h |
|
2 // |
|
3 // Copyright (c) 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 #ifndef KERNLBXMODEL_H |
|
13 #define KERNLBXMODEL_H |
|
14 |
|
15 #include <e32hashtab.h> |
|
16 |
|
17 #include <W32STD.H> |
|
18 |
|
19 class CKernListBoxData; |
|
20 class TObjectKernelInfo; |
|
21 class TThreadKernelInfo; |
|
22 class CUndertaker; |
|
23 class CDlgProcessInfo; |
|
24 class RMemoryAccess; |
|
25 class CApaWindowGroupName; |
|
26 class RClogger; |
|
27 class MKernListBoxDataDelegate; |
|
28 class RWsSession; |
|
29 |
|
30 NONSHARABLE_CLASS(CKernListBoxModel) : public CBase, public TSwap, public TKey |
|
31 { |
|
32 public: // External interface |
|
33 CKernListBoxModel(RMemoryAccess& aMemAccess); |
|
34 ~CKernListBoxModel(); |
|
35 void ConstructL(); |
|
36 void SetCurrentListL(TInt aCurrentList); |
|
37 TInt GetCurrentList() const; |
|
38 void RefreshDataL(TInt aIndex=-1); // -1 means refresh all |
|
39 |
|
40 void DumpToCloggerL(RClogger& aClogger); |
|
41 void CloseAllThreadHandles(); |
|
42 void SummaryInfoL(TDes& aBuf); |
|
43 void Sort(TLinearOrder<CKernListBoxData> aOrder); |
|
44 void SetInfoChangedCallback(TInt aIndex, const TCallBack& aCallback); |
|
45 |
|
46 public: |
|
47 TInt Count() const; |
|
48 TInt ItemIdIndex(TInt aItemId) const; |
|
49 CKernListBoxData* RetrieveDataL(TInt aItemIndex); |
|
50 CKernListBoxData* RetrieveDataLC(TInt aItemIndex); |
|
51 virtual void ModelBeginUpdateLC(); |
|
52 virtual void ModelEndUpdateL(); |
|
53 virtual void RemoveAllDataL(); |
|
54 virtual void DataUpdatedL(TInt aIndex); |
|
55 virtual void RemoveDataL(TInt aItemIndex); |
|
56 virtual void Sort(); |
|
57 |
|
58 |
|
59 protected: // From TSwap,TKey |
|
60 void Swap(TInt aLeft,TInt aRight) const; |
|
61 void WtfSwap(TInt aLeft,TInt aRight); // How on earth can Swap be const?? |
|
62 TInt Compare(TInt aLeft,TInt aRight) const; |
|
63 |
|
64 public: // For helpers to use, not for public use by client |
|
65 void ThreadDiedL(TInt aHandle); |
|
66 virtual void NewKernDataL(TInt aType, TObjectKernelInfo* aInfo); // aInfo ownership transferred at END of function |
|
67 RMemoryAccess& MemAccess() { return iMemAccess; } |
|
68 |
|
69 protected: |
|
70 void DoNewKernDataL(TInt aType, TObjectKernelInfo* aInfo, MKernListBoxDataDelegate* aDelegate); |
|
71 |
|
72 protected: |
|
73 RPointerArray<CKernListBoxData> iItemData; |
|
74 |
|
75 private: |
|
76 TInt iCurrentList; |
|
77 RArray<TInt> iThreadHandleArray; |
|
78 CUndertaker* iUnd; |
|
79 TLinearOrder<CKernListBoxData> iSort; |
|
80 RWsSession* iWsSession; // Needed to keep the window group data objects valid |
|
81 RBuf iTempBuf1, iTempBuf2; // So that calls to FormatL don't need to allocate so much |
|
82 TCallBack iInfoChangedCallback; |
|
83 CKernListBoxData* iCallbackData; |
|
84 RMemoryAccess& iMemAccess; |
|
85 friend class CKernListBoxData; |
|
86 }; |
|
87 |
|
88 class MKernListBoxDataDelegate |
|
89 { |
|
90 public: |
|
91 virtual void DataObjectAboutToDestruct(CKernListBoxData* aData) =0; |
|
92 virtual void FormatChangedL(CKernListBoxData* aData, const TDesC& aTitle, const TDesC& aInfo) =0; |
|
93 virtual TPtrC NameForSortPurposes() const =0; |
|
94 }; |
|
95 |
|
96 |
|
97 NONSHARABLE_CLASS(CKernListBoxData) : public CBase |
|
98 { |
|
99 public: |
|
100 CKernListBoxData(CKernListBoxModel* aModel); |
|
101 ~CKernListBoxData(); |
|
102 void FormatL(TObjectKernelInfo* aInfo, RBuf& aTempBuf1, RBuf& aTempBuf2); |
|
103 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
104 |
|
105 TInt ExeNameForSid(TUint aSid, RBuf& aName); |
|
106 |
|
107 public: |
|
108 void Open(); |
|
109 void Close(); |
|
110 //TInt RefCount() const; |
|
111 TInt ItemId() const; |
|
112 void SetItemId(TInt aItemId); |
|
113 void ConstructL(); |
|
114 void SetDelegate(MKernListBoxDataDelegate* aOwner); |
|
115 MKernListBoxDataDelegate* Delegate(); |
|
116 const MKernListBoxDataDelegate* Delegate() const; |
|
117 CKernListBoxModel& Model(); |
|
118 |
|
119 public: // Things for the dialog to use |
|
120 virtual TBool SupportsCommand(TInt aCommand); |
|
121 void KillL(); |
|
122 void InfoForDialogL(RBuf& aTitle, RBuf& aText, TBool aRefresh); // Pass in false to use cached values if available |
|
123 TAny* GetHandleL(); |
|
124 |
|
125 protected: |
|
126 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
127 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
128 |
|
129 public: |
|
130 TInt iType; |
|
131 TObjectKernelInfo* iInfo; // Either a TObjectKernelInfo* or a SOpenFile* etc |
|
132 private: |
|
133 TInt iItemId; |
|
134 MKernListBoxDataDelegate* iDelegate; |
|
135 TInt iRefCount; |
|
136 CKernListBoxModel* iModel; // This is necessary so we can figure out who the parent of a process is, but it does mean a particualar instance can only be used by one model at once (which is not an issue for us) |
|
137 }; |
|
138 |
|
139 NONSHARABLE_CLASS(COpenFilesListBoxData) : public CKernListBoxData |
|
140 { |
|
141 public: |
|
142 COpenFilesListBoxData(CKernListBoxModel* aModel); |
|
143 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
144 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
145 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
146 }; |
|
147 |
|
148 NONSHARABLE_CLASS(CThreadsListBoxData) : public CKernListBoxData |
|
149 { |
|
150 public: |
|
151 CThreadsListBoxData(CKernListBoxModel* aModel); |
|
152 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
153 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
154 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
155 virtual TBool SupportsCommand(TInt aCommand); |
|
156 }; |
|
157 |
|
158 NONSHARABLE_CLASS(CFeatRegListBoxData) : public CKernListBoxData |
|
159 { |
|
160 public: |
|
161 CFeatRegListBoxData(CKernListBoxModel* aModel); |
|
162 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
163 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
164 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
165 }; |
|
166 |
|
167 NONSHARABLE_CLASS(CServerListBoxData) : public CKernListBoxData |
|
168 { |
|
169 public: |
|
170 CServerListBoxData(CKernListBoxModel* aModel); |
|
171 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
172 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
173 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
174 virtual TBool SupportsCommand(TInt aCommand); |
|
175 }; |
|
176 |
|
177 NONSHARABLE_CLASS(CHalListBoxData) : public CKernListBoxData |
|
178 { |
|
179 public: |
|
180 CHalListBoxData(CKernListBoxModel* aModel); |
|
181 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
182 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
183 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
184 }; |
|
185 |
|
186 NONSHARABLE_CLASS(CWindowGroupListBoxData) : public CKernListBoxData |
|
187 { |
|
188 public: |
|
189 CWindowGroupListBoxData(CKernListBoxModel* aModel); |
|
190 ~CWindowGroupListBoxData(); |
|
191 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
192 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
193 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
194 }; |
|
195 |
|
196 NONSHARABLE_CLASS(CMsgQueListBoxData) : public CKernListBoxData |
|
197 { |
|
198 public: |
|
199 CMsgQueListBoxData(CKernListBoxModel* aModel); |
|
200 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
201 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
202 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
203 }; |
|
204 |
|
205 NONSHARABLE_CLASS(CMutexListBoxData) : public CKernListBoxData |
|
206 { |
|
207 public: |
|
208 CMutexListBoxData(CKernListBoxModel* aModel); |
|
209 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
210 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
211 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
212 }; |
|
213 |
|
214 NONSHARABLE_CLASS(CSemaphoreListBoxData) : public CKernListBoxData |
|
215 { |
|
216 public: |
|
217 CSemaphoreListBoxData(CKernListBoxModel* aModel); |
|
218 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
219 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
220 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
221 }; |
|
222 |
|
223 NONSHARABLE_CLASS(CTimerListBoxData) : public CKernListBoxData |
|
224 { |
|
225 public: |
|
226 CTimerListBoxData(CKernListBoxModel* aModel); |
|
227 virtual void DoFormatL(TObjectKernelInfo* aInfo, RBuf& name, RBuf& more, TInt& itemId); |
|
228 virtual void DumpToCloggerL(RClogger& aClogger, TInt i, TInt count); |
|
229 virtual void DoInfoForDialogL(RBuf& aTitle, RBuf& aText, TDes* aTemp); |
|
230 }; |
|
231 |
|
232 NONSHARABLE_CLASS(CUndertaker) : public CActive |
|
233 { |
|
234 public: |
|
235 CUndertaker(CKernListBoxModel& aModel); |
|
236 ~CUndertaker(); |
|
237 void RunL(); |
|
238 void DoCancel(); |
|
239 void Register(); |
|
240 |
|
241 CKernListBoxModel& iModel; |
|
242 RUndertaker iUnd; |
|
243 TInt iHandle; |
|
244 }; |
|
245 |
|
246 struct SHalInfo |
|
247 { |
|
248 TInt iProperties; |
|
249 TInt iValue; |
|
250 TInt iAttribute; |
|
251 }; |
|
252 |
|
253 struct SWgInfo |
|
254 { |
|
255 TInt iHandle; |
|
256 CApaWindowGroupName* iName; |
|
257 RWsSession* iSession; // Doesn't really belong here (as it will be the same for all objects) but it means the data objects don't have to have a handle to it |
|
258 }; |
|
259 |
|
260 struct SDataType |
|
261 { |
|
262 TBuf<256> iMime; // 256 is KMaxDataTypeLength |
|
263 TFileName iRecog; |
|
264 TFileName iApp; |
|
265 TUid iAppUid; |
|
266 }; |
|
267 |
|
268 struct SOpenFile |
|
269 { |
|
270 TFileName iName; |
|
271 TInt iNumThreads; |
|
272 TFixedArray<TThreadId, 10> iThreadIds; |
|
273 }; |
|
274 |
|
275 struct SFeature |
|
276 { |
|
277 TInt iFeature; |
|
278 TInt iErr; |
|
279 TUint32 iInfo; |
|
280 }; |
|
281 |
|
282 _LIT(Klf, "\n"); |
|
283 _LIT(Klflf, "\n\n"); |
|
284 |
|
285 #endif |