|
1 // Copyright (c) 1998-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 // MSVREG.CPP |
|
15 // |
|
16 |
|
17 #include "MSVREG.H" |
|
18 #include "MSVRUIDS.H" |
|
19 #include "MSVPANIC.H" |
|
20 #include "MsvSecurityCapabilitySet.h" |
|
21 |
|
22 #include <f32file.h> |
|
23 #include <s32strm.h> |
|
24 #include <e32uid.h> |
|
25 |
|
26 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
27 #include "msvconsts.h" |
|
28 #endif |
|
29 |
|
30 /** Creates a new CMtmDllInfo and initialises it with values describing an MTM |
|
31 component. |
|
32 |
|
33 @param aHumanReadableName Descriptor holding a descriptive name for the MTM |
|
34 component |
|
35 @param aUidType Group of UIDs for the MTM. The UIDs should be as follows: UID1: |
|
36 always KDynamicLibraryUid UID2: identifies whether the MTM component is a |
|
37 Client-side MTM, User Interface MTM, UI Data MTM, or Server-side MTM. UID3: |
|
38 identifies this concrete MTM uniquely |
|
39 @param aFilename A full filename (including drive and path) of the MTM dll |
|
40 @param aEntryPointOrdinalNumber Ordinal of factory function for the MTM |
|
41 @param aVersion Version information for the MTM component |
|
42 @leave KErrNoMemory A memory allocation failed |
|
43 @return New CMtmDllInfo initialised with passed values */ |
|
44 EXPORT_C CMtmDllInfo* CMtmDllInfo::NewL(const TDesC& aHumanReadableName,const TUidType& aUidType,const TDesC& aFilename,TInt aEntryPointOrdinalNumber,const TVersion aVersion) |
|
45 { |
|
46 CMtmDllInfo* mtmdllinfo=new(ELeave) CMtmDllInfo(aUidType,aEntryPointOrdinalNumber,aVersion); |
|
47 CleanupStack::PushL(mtmdllinfo); |
|
48 mtmdllinfo->ConstructL(aHumanReadableName, aFilename); |
|
49 CleanupStack::Pop(mtmdllinfo); |
|
50 return mtmdllinfo; |
|
51 } |
|
52 |
|
53 /** Creates a new CMtmDllInfo initialised from another CMtmDllInfo object. |
|
54 |
|
55 @param aMtmDllInfo A CMtmDllInfo object from which to initialise this |
|
56 @leave KErrNoMemory A memory allocation failed |
|
57 @return New CMtmDllInfo initialised with passed CMtmDllInfo */ |
|
58 EXPORT_C CMtmDllInfo* CMtmDllInfo::NewL(const CMtmDllInfo& aMtmDllInfo) |
|
59 { |
|
60 CMtmDllInfo* mtmdllinfo = new(ELeave) CMtmDllInfo(aMtmDllInfo); |
|
61 CleanupStack::PushL(mtmdllinfo); |
|
62 mtmdllinfo->ConstructL(*aMtmDllInfo.iHumanReadableName, *aMtmDllInfo.iFilename); |
|
63 CleanupStack::Pop(mtmdllinfo); |
|
64 return mtmdllinfo; |
|
65 } |
|
66 |
|
67 |
|
68 /** Creates a new CMtmDllInfo and initialises it with values read from a stream. |
|
69 |
|
70 The contents of the stream to read will have been created by CMtmDllInfo::ExternalizeL(). |
|
71 |
|
72 @param aStream Stream to read from |
|
73 @leave KErrNoMemory A memory allocation failed |
|
74 @return New CMtmDllInfo */ |
|
75 EXPORT_C CMtmDllInfo* CMtmDllInfo::NewL(RReadStream& aStream) |
|
76 { |
|
77 CMtmDllInfo* mtmdllinfo=new(ELeave) CMtmDllInfo(); |
|
78 CleanupStack::PushL(mtmdllinfo); |
|
79 mtmdllinfo->InternalizeL(aStream); |
|
80 CleanupStack::Pop(); |
|
81 return mtmdllinfo; |
|
82 } |
|
83 |
|
84 /** Destructor. */ |
|
85 EXPORT_C CMtmDllInfo::~CMtmDllInfo() |
|
86 { |
|
87 delete iHumanReadableName; |
|
88 delete iFilename; |
|
89 } |
|
90 |
|
91 EXPORT_C void CMtmDllInfo::SetHumanReadableNameL(const TDesC& aHumanReadableName) |
|
92 /** Sets the descriptive name of the MTM component for which the object holds registration |
|
93 data. |
|
94 |
|
95 @param aHumanReadableName Descriptor holding a descriptive name for the MTM |
|
96 component */ |
|
97 { |
|
98 __ASSERT_DEBUG(aHumanReadableName.Length()<=KHumanReadableNameLength,PanicServer(EMsvHumanReadableNameTooLong)); |
|
99 HBufC* humanreadablename=HBufC::NewL(aHumanReadableName.Length()); |
|
100 delete iHumanReadableName; |
|
101 iHumanReadableName=humanreadablename; |
|
102 iHumanReadableName->Des().Copy(aHumanReadableName); |
|
103 } |
|
104 |
|
105 /** Internalises the object from a stream. |
|
106 |
|
107 The contents of the stream to read will have been created by CMtmDllInfo::ExternalizeL(). |
|
108 |
|
109 @param aStream Stream to read from |
|
110 @leave Error Standard streaming errors |
|
111 */ |
|
112 EXPORT_C void CMtmDllInfo::InternalizeL(RReadStream& aStream) |
|
113 { |
|
114 HBufC* humanreadablename=HBufC::NewL(aStream,KHumanReadableNameLength); |
|
115 delete iHumanReadableName; |
|
116 iHumanReadableName=humanreadablename; |
|
117 iMessagingCapability = aStream.ReadInt8L(); |
|
118 iSendBodyCapability = aStream.ReadInt8L(); |
|
119 iCapabilitiesAvailable = aStream.ReadInt8L(); |
|
120 TUid uid1,uid2,uid3; |
|
121 aStream >> uid1; |
|
122 aStream >> uid2; |
|
123 aStream >> uid3; |
|
124 TUidType uidtype(uid1,uid2,uid3); |
|
125 iUidType=uidtype; |
|
126 iEntryPointOrdinalNumber=aStream.ReadInt32L(); |
|
127 iVersion.iMajor=aStream.ReadInt8L(); |
|
128 iVersion.iMinor=aStream.ReadInt8L(); |
|
129 iVersion.iBuild=aStream.ReadInt16L(); |
|
130 HBufC* temp; |
|
131 if (uid3.iUid == KUidMtmDefaultSpecificVal) |
|
132 { |
|
133 // We can assume we are reading data from an updated stream. |
|
134 // The version number should be <= 2.0. |
|
135 __ASSERT_DEBUG((iVersion.iMajor < KMtmComponentCurrentMajorVersionNumber) || (iVersion.iMajor == KMtmComponentCurrentMajorVersionNumber&& iVersion.iMinor == KMtmComponentCurrentMinorVersionNumber), PanicServer(EMsvBadMtmVersionNumber)); |
|
136 |
|
137 temp = HBufC::NewL(aStream, KMaxFileName); |
|
138 } |
|
139 else |
|
140 { |
|
141 // Just create a zero length filename for old versions |
|
142 temp = KNullDesC().AllocL(); |
|
143 } |
|
144 delete iFilename; |
|
145 iFilename = temp; |
|
146 } |
|
147 |
|
148 |
|
149 // no longer used but as it is exported it has been kept |
|
150 /** Externalises the object to a stream. |
|
151 |
|
152 @param aStream Stream to write to |
|
153 @leave Error Standard streaming errors |
|
154 */ |
|
155 EXPORT_C void CMtmDllInfo::ExternalizeL(RWriteStream& aStream) const |
|
156 { |
|
157 aStream << *iHumanReadableName; |
|
158 aStream.WriteInt8L(iMessagingCapability); |
|
159 aStream.WriteInt8L(iSendBodyCapability); |
|
160 aStream.WriteInt8L(iCapabilitiesAvailable); |
|
161 aStream << iUidType[0]; |
|
162 aStream << iUidType[1]; |
|
163 aStream << iUidType[2]; |
|
164 aStream.WriteInt32L(iEntryPointOrdinalNumber); |
|
165 aStream.WriteInt8L(iVersion.iMajor); |
|
166 aStream.WriteInt8L(iVersion.iMinor); |
|
167 aStream.WriteInt16L(iVersion.iBuild); |
|
168 if (iUidType[2].iUid == KUidMtmDefaultSpecificVal) |
|
169 { |
|
170 // The version number should be <= 2.0. |
|
171 __ASSERT_DEBUG((iVersion.iMajor < KMtmComponentCurrentMajorVersionNumber) || (iVersion.iMajor == KMtmComponentCurrentMajorVersionNumber && iVersion.iMinor == KMtmComponentCurrentMinorVersionNumber), PanicServer(EMsvBadMtmVersionNumber)); |
|
172 |
|
173 aStream << FileName(); |
|
174 } |
|
175 } |
|
176 |
|
177 /** Overloaded equality operator. |
|
178 @param aMtmDllInfo Object to compare |
|
179 @return True if the iFileName member and the UIDs (iUidType member) are the same in both objects, |
|
180 otherwise false |
|
181 */ |
|
182 |
|
183 EXPORT_C TBool CMtmDllInfo::operator==(const CMtmDllInfo& aMtmDllInfo) const |
|
184 { |
|
185 return (FileName().CompareF(aMtmDllInfo.FileName()) == 0 && (iUidType==aMtmDllInfo.iUidType)); |
|
186 } |
|
187 |
|
188 CMtmDllInfo::CMtmDllInfo(const TUidType& aUidType,TInt aEntryPointOrdinalNumber,const TVersion aVersion): |
|
189 iUidType(aUidType), |
|
190 iEntryPointOrdinalNumber(aEntryPointOrdinalNumber), |
|
191 iVersion(aVersion) |
|
192 { |
|
193 __DECLARE_NAME(_S("CMtmDllInfo")); |
|
194 } |
|
195 |
|
196 |
|
197 CMtmDllInfo::CMtmDllInfo() |
|
198 { |
|
199 } |
|
200 |
|
201 CMtmDllInfo::CMtmDllInfo(const CMtmDllInfo& aMtmDllInfo): |
|
202 iUidType(aMtmDllInfo.iUidType), |
|
203 iEntryPointOrdinalNumber(aMtmDllInfo.iEntryPointOrdinalNumber), |
|
204 iVersion(aMtmDllInfo.iVersion), |
|
205 iMessagingCapability(aMtmDllInfo.iMessagingCapability), |
|
206 iSendBodyCapability(aMtmDllInfo.iSendBodyCapability), |
|
207 iCapabilitiesAvailable(aMtmDllInfo.iCapabilitiesAvailable) |
|
208 { |
|
209 } |
|
210 |
|
211 void CMtmDllInfo::ConstructL(const TDesC& aHumanReadableName, const TDesC& aFilename) |
|
212 { |
|
213 iHumanReadableName = aHumanReadableName.AllocL(); |
|
214 iFilename = aFilename.AllocL(); |
|
215 } |
|
216 |
|
217 TPtrC CMtmDllInfo::FileName() const |
|
218 { |
|
219 return *iFilename; |
|
220 } |
|
221 |
|
222 |
|
223 /** Sets a flag to indicate that the MTM can send messages. |
|
224 |
|
225 @param aCapability True to set the flag, false to clear it |
|
226 */ |
|
227 void CMtmDllInfo::SetMessagingCapability(TBool aCapability) |
|
228 { |
|
229 iMessagingCapability = aCapability; |
|
230 } |
|
231 |
|
232 |
|
233 /** Sets a flag to indicate that the MTM can handle body text. |
|
234 |
|
235 @param aCapability True to set the flag, false to clear it |
|
236 */ |
|
237 void CMtmDllInfo::SetSendBodyCapability(TBool aCapability) |
|
238 { |
|
239 iSendBodyCapability = aCapability; |
|
240 } |
|
241 |
|
242 /** Sets a flag to indicate that settings have been made for |
|
243 the MessagingCapability() and SendBodyCapability() flags. |
|
244 |
|
245 These settings are optional, so may not have been made |
|
246 for all MTMs. |
|
247 @param aCapability True if the settings exist; otherwise false |
|
248 */ |
|
249 void CMtmDllInfo::SetCapabilitiesAvailable(TBool aCapability) |
|
250 { |
|
251 iCapabilitiesAvailable = aCapability; |
|
252 } |
|
253 |
|
254 /** Tests if the flag that indicates that the MTM can send |
|
255 messages has been set. |
|
256 |
|
257 @return True if the flag has been set; otherwise false |
|
258 */ |
|
259 EXPORT_C TBool CMtmDllInfo::MessagingCapability() const |
|
260 { |
|
261 return iMessagingCapability; |
|
262 } |
|
263 |
|
264 /** Tests if the flag that indicates that the MTM can handle |
|
265 body text has been set. |
|
266 |
|
267 @return True if the flag has been set; otherwise false |
|
268 */ |
|
269 EXPORT_C TBool CMtmDllInfo::SendBodyCapability() const |
|
270 { |
|
271 return iSendBodyCapability; |
|
272 } |
|
273 |
|
274 /** Tests if settings have been made for the MessagingCapability() |
|
275 and SendBodyCapability() flags. |
|
276 |
|
277 These settings are optional, so may not have been made |
|
278 for all MTMs. |
|
279 @return True if the settings exist; otherwise false |
|
280 */ |
|
281 EXPORT_C TBool CMtmDllInfo::CapabilitiesAvailable() const |
|
282 { |
|
283 return iCapabilitiesAvailable; |
|
284 } |
|
285 |
|
286 /** Default constructor. */ |
|
287 EXPORT_C CMtmDllInfoArray::CMtmDllInfoArray(): |
|
288 CArrayPtrFlat<CMtmDllInfo>(8) |
|
289 { |
|
290 __DECLARE_NAME(_S("CMtmDllInfoArray")); |
|
291 } |
|
292 |
|
293 /** Destructor. */ |
|
294 EXPORT_C CMtmDllInfoArray::~CMtmDllInfoArray() |
|
295 { |
|
296 ResetAndDestroy(); |
|
297 } |
|
298 |
|
299 EXPORT_C void CMtmDllInfoArray::AddMtmDllInfoL(CMtmDllInfo* aMtmDllInfo) |
|
300 /** Appends a CMtmDllInfo to the array. |
|
301 |
|
302 @param aMtmDllInfo CMtmDllInfo to append |
|
303 @leave KErrNoMemory A memory allocation failed */ |
|
304 { |
|
305 CleanupStack::PushL(aMtmDllInfo); |
|
306 AppendL(aMtmDllInfo); |
|
307 CleanupStack::Pop(); |
|
308 } |
|
309 |
|
310 |
|
311 |
|
312 /** Creates a new CMtmGroupData and initialise it with registration data for an |
|
313 MTM group. |
|
314 |
|
315 @param aMtmTypeUid UID that uniquely identifies the MTM group |
|
316 @param aTechnologyTypeUid UID that can be used to indicate the messaging technology |
|
317 which the MTM group implements |
|
318 @param aMtmDllInfoArray Array of registration data for the MTM components in |
|
319 the group. This function takes immediate responsibility for aMtmDllInfoArray, |
|
320 so it should not be on the cleanup stack prior to the call. If successful, |
|
321 the newly created CMtmGroupData takes ownership of the object |
|
322 @param aMtmRequiredCaps The required security capabilities for this MTM group |
|
323 @leave KErrNoMemory A memory allocation failed |
|
324 @return New initialised CMtmGroupData */ |
|
325 |
|
326 EXPORT_C CMtmGroupData* CMtmGroupData::NewL(TUid aMtmTypeUid, TUid aTechnologyTypeUid, CMtmDllInfoArray* aMtmDllInfoArray, const TCapabilitySet& aMtmRequiredCaps) |
|
327 { |
|
328 __ASSERT_DEBUG(aMtmDllInfoArray != NULL, PanicServer(EMsvConstructWithNullDllInfoArray)); |
|
329 CleanupStack::PushL(aMtmDllInfoArray); |
|
330 CMtmGroupData* self = new(ELeave) CMtmGroupData(aMtmTypeUid, aTechnologyTypeUid, aMtmDllInfoArray, aMtmRequiredCaps); |
|
331 CleanupStack::Pop(aMtmDllInfoArray); |
|
332 return self; |
|
333 } |
|
334 |
|
335 /** Creates a new CMtmGroupData and initialises it with another CMtmGroupData |
|
336 |
|
337 @param aMtmTypeGroupData Another CMtmGroupData from which to copy |
|
338 @leave KErrNoMemory A memory allocation failed |
|
339 @return New initialised CMtmGroupData */ |
|
340 |
|
341 EXPORT_C CMtmGroupData* CMtmGroupData::NewL(const CMtmGroupData& aMtmGroupData) |
|
342 { |
|
343 CMtmGroupData* self = new(ELeave) CMtmGroupData(aMtmGroupData.iMtmTypeUid, aMtmGroupData.iTechnologyTypeUid, NULL, aMtmGroupData.iMtmRequiredCaps); |
|
344 CleanupStack::PushL(self); |
|
345 self->ConstructL(aMtmGroupData); |
|
346 CleanupStack::Pop(self); |
|
347 return self; |
|
348 } |
|
349 |
|
350 CMtmGroupData::CMtmGroupData(TUid aMtmTypeUid, TUid aTechnologyTypeUid, CMtmDllInfoArray* aMtmDllInfoArray,const TCapabilitySet& aMtmRequiredCaps): |
|
351 iMtmTypeUid(aMtmTypeUid), |
|
352 iTechnologyTypeUid(aTechnologyTypeUid), |
|
353 iMtmDllInfoArray(aMtmDllInfoArray), |
|
354 iMtmRequiredCaps(aMtmRequiredCaps) |
|
355 { |
|
356 } |
|
357 |
|
358 void CMtmGroupData::AppendMtmDllInfoArrayL(const CMtmDllInfoArray& aMtmDllInfoArray) |
|
359 { |
|
360 TInt count=aMtmDllInfoArray.Count(); |
|
361 for (TInt ii=0; ii<count; ++ii) |
|
362 { |
|
363 CMtmDllInfo* mtmdllinfo = CMtmDllInfo::NewL(*aMtmDllInfoArray[ii]); |
|
364 AppendMtmDllInfoL(mtmdllinfo); |
|
365 } |
|
366 } |
|
367 |
|
368 void CMtmGroupData::ConstructL(const CMtmGroupData& aMtmGroupData) |
|
369 { |
|
370 iMtmDllInfoArray = new(ELeave) CMtmDllInfoArray(); |
|
371 AppendMtmDllInfoArrayL(aMtmGroupData.MtmDllInfoArray()); |
|
372 } |
|
373 |
|
374 void CMtmGroupData::ConstructL() |
|
375 { |
|
376 iMtmDllInfoArray = new(ELeave) CMtmDllInfoArray(); |
|
377 } |
|
378 |
|
379 |
|
380 EXPORT_C CMtmGroupData* CMtmGroupData::NewL(RReadStream& aStream) |
|
381 /** Creates a new CMtmGroupData and initialises it from the specified stream. |
|
382 |
|
383 @param aStream Stream from which to read previously externalised CMtmGroupData |
|
384 |
|
385 @leave KErrNoMemory A memory allocation failed |
|
386 @return New initialised CMtmGroupData */ |
|
387 { |
|
388 CMtmGroupData* mtmgroupdata=new(ELeave) CMtmGroupData(); |
|
389 CleanupStack::PushL(mtmgroupdata); |
|
390 mtmgroupdata->ConstructL(); |
|
391 mtmgroupdata->InternalizeL(aStream); |
|
392 CleanupStack::Pop(); |
|
393 return mtmgroupdata; |
|
394 } |
|
395 |
|
396 /** Destructor. */ |
|
397 EXPORT_C CMtmGroupData::~CMtmGroupData() |
|
398 { |
|
399 delete iMtmDllInfoArray; |
|
400 } |
|
401 |
|
402 EXPORT_C void CMtmGroupData::InternalizeL(RReadStream& aStream) |
|
403 /** Internalises group registration data. |
|
404 |
|
405 @param aStream Stream from which to internalise object */ |
|
406 { |
|
407 MtmDllInfoArrayPrivate().ResetAndDestroy(); |
|
408 aStream >> iMtmTypeUid; |
|
409 aStream >> iTechnologyTypeUid; |
|
410 TInt count=aStream.ReadInt32L(); |
|
411 for (TInt i=0; i<count; i++) |
|
412 { |
|
413 CMtmDllInfo* mtmdllinfo=CMtmDllInfo::NewL(aStream); |
|
414 AppendMtmDllInfoL(mtmdllinfo); |
|
415 } |
|
416 MsvSecurityCapabilitySetUtils::InternalizeL(aStream,iMtmRequiredCaps); |
|
417 } |
|
418 |
|
419 |
|
420 /** Returns a constant reference to the array of MTM dll information objects owned by the CMtmGroupData. |
|
421 |
|
422 @return A constant reference to the MTM dll info array*/ |
|
423 |
|
424 EXPORT_C const CMtmDllInfoArray& CMtmGroupData::MtmDllInfoArray() const |
|
425 { |
|
426 // Return a const reference to the dll info array |
|
427 __ASSERT_DEBUG(iMtmDllInfoArray != NULL, PanicServer(EMsvAttemptToUseNullDllInfoArray)); |
|
428 return *iMtmDllInfoArray; |
|
429 } |
|
430 |
|
431 CMtmDllInfoArray& CMtmGroupData::MtmDllInfoArrayPrivate() |
|
432 { |
|
433 // Return a non-const reference to the dll info array. Only for use within |
|
434 // this class |
|
435 __ASSERT_DEBUG(iMtmDllInfoArray != NULL, PanicServer(EMsvAttemptToUseNullDllInfoArray)); |
|
436 return *iMtmDllInfoArray; |
|
437 } |
|
438 |
|
439 EXPORT_C const TCapabilitySet& CMtmGroupData::GetMtmRequiredCapabilities() const |
|
440 { |
|
441 return iMtmRequiredCaps; |
|
442 } |
|
443 |
|
444 |
|
445 // not used but as it is exported it has been kept |
|
446 EXPORT_C void CMtmGroupData::ExternalizeL(RWriteStream& aStream) const |
|
447 /** Externalises group registration data. |
|
448 |
|
449 This is the method by which registration data is written to a MTM registration |
|
450 data file. |
|
451 |
|
452 @param aStream Stream to which to externalise object */ |
|
453 { |
|
454 aStream << iMtmTypeUid; |
|
455 aStream << iTechnologyTypeUid; |
|
456 const CMtmDllInfoArray& mtmDllInfoArray = MtmDllInfoArray(); |
|
457 TInt count=mtmDllInfoArray.Count(); |
|
458 aStream.WriteInt32L(count); |
|
459 for (TInt ii=0; ii<count; ++ii) |
|
460 aStream << *mtmDllInfoArray[ii]; |
|
461 |
|
462 MsvSecurityCapabilitySetUtils::ExternalizeL(aStream,iMtmRequiredCaps); |
|
463 } |
|
464 |
|
465 EXPORT_C TBool CMtmGroupData::operator==(const CMtmGroupData& aMtmGroupData) const |
|
466 /** Tests for equality with another CMtmGroupData object. |
|
467 |
|
468 @param aMtmGroupData CMtmGroupData object with which to compare |
|
469 @return ETrue: equal, EFalse: unequal. */ |
|
470 { |
|
471 TBool isequal=((iMtmTypeUid==aMtmGroupData.iMtmTypeUid) && (iTechnologyTypeUid==aMtmGroupData.iTechnologyTypeUid)); |
|
472 if (isequal) |
|
473 { |
|
474 const CMtmDllInfoArray& mtmDllInfoArray1 = MtmDllInfoArray(); |
|
475 const CMtmDllInfoArray& mtmDllInfoArray2 = aMtmGroupData.MtmDllInfoArray(); |
|
476 TInt count1=mtmDllInfoArray1.Count(); |
|
477 TInt count2=mtmDllInfoArray2.Count(); |
|
478 TBool isequal=(count1==count2); |
|
479 for (TInt ii=0; (ii<count1) && isequal; ++ii) |
|
480 isequal=(mtmDllInfoArray1[ii]==mtmDllInfoArray2[ii]); |
|
481 } |
|
482 if (isequal) |
|
483 { |
|
484 isequal = (iMtmRequiredCaps.HasCapabilities(aMtmGroupData.iMtmRequiredCaps) |
|
485 && aMtmGroupData.iMtmRequiredCaps.HasCapabilities(iMtmRequiredCaps)); |
|
486 } |
|
487 return isequal; |
|
488 } |
|
489 |
|
490 CMtmGroupData::CMtmGroupData(TUid aMtmTypeUid,TUid aTechnologyTypeUid): |
|
491 iMtmTypeUid(aMtmTypeUid), |
|
492 iTechnologyTypeUid(aTechnologyTypeUid) |
|
493 { |
|
494 __DECLARE_NAME(_S("CMtmGroupData")); |
|
495 } |
|
496 |
|
497 |
|
498 void CMtmGroupData::AppendMtmDllInfoL(CMtmDllInfo* aMtmDllInfo) |
|
499 { |
|
500 CMtmDllInfoArray& mtmDllInfoArray = MtmDllInfoArrayPrivate(); |
|
501 TInt index = mtmDllInfoArray.Count(); |
|
502 CleanupStack::PushL(aMtmDllInfo); |
|
503 if (index==KMsvNumMtmDllTypes) |
|
504 User::Leave(KErrNotSupported); // There may be a better error value |
|
505 if (aMtmDllInfo->iUidType[0]!=KDynamicLibraryUid) |
|
506 User::Leave(KErrNotSupported); |
|
507 |
|
508 TUid mtmdlltypeuid[KMsvNumMtmDllTypes] = { KUidMtmServerComponentVal, KUidMtmClientComponentVal, KUidMtmUiComponentVal, KUidMtmUiDataComponentVal }; |
|
509 __ASSERT_DEBUG(aMtmDllInfo->iUidType[1]==mtmdlltypeuid[index],PanicServer(EMsvMtmDllInfoSecondUidIncorrect)); |
|
510 if (aMtmDllInfo->iUidType[1]!=mtmdlltypeuid[index]) |
|
511 User::Leave(KErrNotSupported); |
|
512 mtmDllInfoArray.AppendL(aMtmDllInfo); |
|
513 CleanupStack::Pop(aMtmDllInfo); |
|
514 } |
|
515 |
|
516 /** |
|
517 @internalComponent |
|
518 */ |
|
519 EXPORT_C CRegisteredMtmDll* CRegisteredMtmDll::NewL(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const CMtmDllInfo& aMtmDllInfo,const TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver) |
|
520 { |
|
521 CRegisteredMtmDll* registereredmtmdll=new(ELeave) CRegisteredMtmDll(aMtmTypeUid,aTechnologyTypeUid,aTimeoutMicroSeconds32,aRegisteredMtmDllObserver); |
|
522 CleanupStack::PushL(registereredmtmdll); |
|
523 registereredmtmdll->ConstructL(aMtmDllInfo); |
|
524 CleanupStack::Pop(); |
|
525 return registereredmtmdll; |
|
526 } |
|
527 |
|
528 EXPORT_C CRegisteredMtmDll::~CRegisteredMtmDll() |
|
529 { |
|
530 __ASSERT_DEBUG(iMtmDllRefCount==0,PanicServer(EMsvRegisteredMtmDllStillInUse)); |
|
531 Cancel(); |
|
532 delete iMtmDllInfo; |
|
533 iMtmDllLibrary.Close(); |
|
534 } |
|
535 |
|
536 /** |
|
537 @internalComponent |
|
538 */ |
|
539 EXPORT_C TInt CRegisteredMtmDll::GetLibrary(RFs& aFs,RLibrary& aMtmDllLibrary) |
|
540 { |
|
541 TInt ret=KErrNone; |
|
542 if (iMtmDllRefCount==0) |
|
543 TRAP(ret,LoadLibraryL(aFs)); |
|
544 if (ret==KErrNone) |
|
545 { |
|
546 aMtmDllLibrary=iMtmDllLibrary; |
|
547 iMtmDllRefCount++; |
|
548 } |
|
549 else |
|
550 iMtmDllLibrary.Close(); |
|
551 return ret; |
|
552 } |
|
553 |
|
554 /** |
|
555 @internalComponent |
|
556 */ |
|
557 EXPORT_C void CRegisteredMtmDll::ReleaseLibrary() |
|
558 { |
|
559 __ASSERT_DEBUG(iMtmDllRefCount>0,PanicServer(EMsvRegisteredMtmDllRefCountZero)); |
|
560 iMtmDllRefCount--; |
|
561 if (iMtmDllRefCount==0) |
|
562 { |
|
563 iRegisteredMtmDllObserver.ReleaseMtmGroup(iMtmTypeUid); // Ignore error returned, this is safe client side |
|
564 After(iTimeoutMicroSeconds32); |
|
565 } |
|
566 } |
|
567 |
|
568 CRegisteredMtmDll::CRegisteredMtmDll(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver): |
|
569 CTimer(EPriorityLow), |
|
570 iMtmTypeUid(aMtmTypeUid), |
|
571 iTechnologyTypeUid(aTechnologyTypeUid), |
|
572 iTimeoutMicroSeconds32(aTimeoutMicroSeconds32), |
|
573 iRegisteredMtmDllObserver(aRegisteredMtmDllObserver) |
|
574 { |
|
575 __DECLARE_NAME(_S("CRegisteredMtmDll")); |
|
576 CActiveScheduler::Add(this); |
|
577 } |
|
578 |
|
579 void CRegisteredMtmDll::ConstructL(const CMtmDllInfo& aMtmDllInfo) |
|
580 { |
|
581 CTimer::ConstructL(); |
|
582 iMtmDllInfo = CMtmDllInfo::NewL(aMtmDllInfo); |
|
583 } |
|
584 |
|
585 void CRegisteredMtmDll::LoadLibraryL(RFs& /*aFs*/) |
|
586 { |
|
587 __ASSERT_DEBUG(iMtmDllRefCount==0,PanicServer(EMsvRegisteredMtmDllRefCountNonZero)); |
|
588 Cancel(); // Cancel timer |
|
589 if (iMtmDllLibrary.Handle()==0) |
|
590 { |
|
591 // Secure API and old UID support removed - load by filename |
|
592 User::LeaveIfError(iMtmDllLibrary.Load(iMtmDllInfo->FileName())); |
|
593 } |
|
594 User::LeaveIfError(iRegisteredMtmDllObserver.UseMtmGroup(iMtmTypeUid)); |
|
595 } |
|
596 |
|
597 |
|
598 void CRegisteredMtmDll::RunL() |
|
599 { |
|
600 iMtmDllLibrary.Close(); |
|
601 } |
|
602 |
|
603 |
|
604 EXPORT_C CRegisteredMtmDllArray::CRegisteredMtmDllArray(): |
|
605 CArrayPtrFlat<CRegisteredMtmDll>(8) |
|
606 { |
|
607 __DECLARE_NAME(_S("CRegisteredMtmDllArray")); |
|
608 } |
|
609 |
|
610 EXPORT_C CRegisteredMtmDllArray::~CRegisteredMtmDllArray() |
|
611 { |
|
612 ResetAndDestroy(); |
|
613 } |
|
614 |
|
615 EXPORT_C void CRegisteredMtmDllArray::AddRegisteredMtmDllL(CRegisteredMtmDll* aRegisteredMtmDll) |
|
616 { |
|
617 CleanupStack::PushL(aRegisteredMtmDll); |
|
618 AppendL(aRegisteredMtmDll); |
|
619 CleanupStack::Pop(); |
|
620 } |
|
621 |
|
622 EXPORT_C CMtmDllRegistry::~CMtmDllRegistry() |
|
623 { |
|
624 } |
|
625 |
|
626 EXPORT_C TUid CMtmDllRegistry::MtmTypeUid(TInt anIndex) const |
|
627 /** Gets the MTM UID of a registered MTM using its index. |
|
628 |
|
629 @param anIndex Indexed of registered MTM |
|
630 @return MTM UID */ |
|
631 { |
|
632 __ASSERT_DEBUG((0<=anIndex) && (anIndex<iRegisteredMtmDllArray.Count()),PanicServer(EMsvRegisteredMtmDllIndexOutRange)); |
|
633 return iRegisteredMtmDllArray[anIndex]->MtmTypeUid(); |
|
634 } |
|
635 |
|
636 EXPORT_C TUid CMtmDllRegistry::TechnologyTypeUid(TUid aMtmTypeUid) const |
|
637 /** Gets the technology type UID for the specified MTM. |
|
638 |
|
639 @param aMtmTypeUid UID of MTM |
|
640 @return Technology type UID */ |
|
641 { |
|
642 __ASSERT_DEBUG(IsPresent(aMtmTypeUid),PanicServer(EMsvRegisteredMtmDllNotFound)); |
|
643 TInt index=MtmTypeUidToIndex(aMtmTypeUid); |
|
644 return iRegisteredMtmDllArray[index]->TechnologyTypeUid(); |
|
645 } |
|
646 |
|
647 EXPORT_C const CMtmDllInfo& CMtmDllRegistry::RegisteredMtmDllInfo(TUid aMtmTypeUid) const |
|
648 /** Gets the registration data for the specified MTM. |
|
649 |
|
650 @param aMtmTypeUid UID of MTM |
|
651 @return Registration data for MTM */ |
|
652 { |
|
653 __ASSERT_DEBUG(IsPresent(aMtmTypeUid),PanicServer(EMsvRegisteredMtmDllNotFound)); |
|
654 TInt index=MtmTypeUidToIndex(aMtmTypeUid); |
|
655 return iRegisteredMtmDllArray[index]->MtmDllInfo(); |
|
656 } |
|
657 |
|
658 EXPORT_C TBool CMtmDllRegistry::IsInUse(TUid aMtmTypeUid) const |
|
659 /** Tests if the MTM with the specified UID is in use. You should check that the |
|
660 MTM is registered, through IsPresent(), before calling this function. |
|
661 |
|
662 @param aMtmTypeUid UID of MTM to check |
|
663 @return ETrue if the specified MTM in use, else EFalse */ |
|
664 { |
|
665 __ASSERT_DEBUG(IsPresent(aMtmTypeUid),PanicServer(EMsvRegisteredMtmDllNotFound)); |
|
666 TInt index=MtmTypeUidToIndex(aMtmTypeUid); |
|
667 return iRegisteredMtmDllArray[index]->MtmDllRefCount()>0; |
|
668 } |
|
669 |
|
670 EXPORT_C TBool CMtmDllRegistry::IsInUse() const |
|
671 /** Tests if any registered MTM is in use. |
|
672 |
|
673 @return ETrue if any MTM in use, else EFalse */ |
|
674 { |
|
675 TInt count=iRegisteredMtmDllArray.Count(); |
|
676 TBool isinuse=EFalse; |
|
677 for (TInt i=0; (i<count) && (!isinuse); i++) |
|
678 isinuse=iRegisteredMtmDllArray[i]->MtmDllRefCount()>0; |
|
679 return isinuse; |
|
680 } |
|
681 |
|
682 EXPORT_C CMtmDllRegistry::CMtmDllRegistry(RFs& aFs,TUid aMtmDllTypeUid,TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32): |
|
683 iFs(aFs), |
|
684 iMtmDllTypeUid(aMtmDllTypeUid), |
|
685 iTimeoutMicroSeconds32(aTimeoutMicroSeconds32) |
|
686 { |
|
687 __DECLARE_NAME(_S("CMtmDllRegistry")); |
|
688 } |
|
689 |
|
690 EXPORT_C TInt CMtmDllRegistry::MtmTypeUidToIndex(TUid anMtmTypeUid) const |
|
691 { |
|
692 TInt i=0, count=iRegisteredMtmDllArray.Count(); |
|
693 for (;(i<count) && (iRegisteredMtmDllArray[i]->MtmTypeUid()!=anMtmTypeUid); i++) |
|
694 { |
|
695 } |
|
696 return i; |
|
697 } |
|
698 |
|
699 EXPORT_C TInt CMtmDllRegistry::AddRegisteredMtmDll(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const CMtmDllInfo& aMtmDllInfo,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver) |
|
700 { |
|
701 __ASSERT_DEBUG(!IsPresent(aMtmTypeUid),PanicServer(EMsvRegisteredMtmDllHasSameMtmTypeUid)); |
|
702 __ASSERT_DEBUG(aMtmDllInfo.iUidType[0]==KDynamicLibraryUid,PanicServer(EMsvRegisteredMtmDllHasSameMtmTypeUid)); |
|
703 __ASSERT_DEBUG(aMtmDllInfo.iUidType[1]==iMtmDllTypeUid,PanicServer(EMsvRegisteredMtmDllHasSameMtmTypeUid)); |
|
704 TRAPD(ret,DoAddRegisteredMtmDllL(aMtmTypeUid,aTechnologyTypeUid,aMtmDllInfo,aRegisteredMtmDllObserver)); |
|
705 return ret; |
|
706 } |
|
707 |
|
708 EXPORT_C void CMtmDllRegistry::RemoveRegisteredMtmDll(TUid aMtmTypeUid) |
|
709 { |
|
710 TInt index=MtmTypeUidToIndex(aMtmTypeUid); |
|
711 __ASSERT_DEBUG(index<iRegisteredMtmDllArray.Count(),PanicServer(EMsvRegisteredMtmDllNotFound)); |
|
712 __ASSERT_DEBUG(iRegisteredMtmDllArray[index]->MtmDllRefCount()==0,PanicServer(EMsvRegisteredMtmDllStillInUse)); |
|
713 delete iRegisteredMtmDllArray[index]; |
|
714 iRegisteredMtmDllArray.Delete(index); |
|
715 } |
|
716 |
|
717 EXPORT_C void CMtmDllRegistry::RemoveAllRegisteredMtmDlls() |
|
718 { |
|
719 iRegisteredMtmDllArray.ResetAndDestroy(); |
|
720 } |
|
721 |
|
722 void CMtmDllRegistry::DoAddRegisteredMtmDllL(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const CMtmDllInfo& aMtmDllInfo,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver) |
|
723 { |
|
724 CRegisteredMtmDll* registeredmtmdll=CRegisteredMtmDll::NewL(aMtmTypeUid,aTechnologyTypeUid,aMtmDllInfo,iTimeoutMicroSeconds32,aRegisteredMtmDllObserver); |
|
725 iRegisteredMtmDllArray.AddRegisteredMtmDllL(registeredmtmdll); |
|
726 } |
|
727 |
|
728 |
|
729 |