|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #include "cimmobilitytesttls.h" |
|
17 #include "cimmobilitytestframework.h" |
|
18 #include "cimmobilitymanager.h" |
|
19 |
|
20 /** |
|
21 Factory constructor |
|
22 Static routine |
|
23 |
|
24 @return Constructed class |
|
25 */ |
|
26 CImMobilityTestTls* CImMobilityTestTls::NewL() |
|
27 { |
|
28 CImMobilityTestTls* self = static_cast<CImMobilityTestTls*>(Dll::Tls()); |
|
29 |
|
30 if (!self) |
|
31 { |
|
32 self = new (ELeave) CImMobilityTestTls(); |
|
33 CleanupStack::PushL(self); |
|
34 self->ConstructL(); |
|
35 CleanupStack::Pop(self); |
|
36 Dll::SetTls(self); |
|
37 } |
|
38 |
|
39 return self; |
|
40 } |
|
41 |
|
42 /** |
|
43 Class constructor |
|
44 */ |
|
45 CImMobilityTestTls::CImMobilityTestTls() |
|
46 { |
|
47 } |
|
48 |
|
49 /** |
|
50 Second phase constructor |
|
51 */ |
|
52 void CImMobilityTestTls::ConstructL() |
|
53 { |
|
54 } |
|
55 |
|
56 /** |
|
57 Class destructor |
|
58 */ |
|
59 CImMobilityTestTls::~CImMobilityTestTls() |
|
60 { |
|
61 iFrameworkList.Reset(); |
|
62 |
|
63 Dll::SetTls(NULL); |
|
64 } |
|
65 |
|
66 /** |
|
67 Stores a test framework. Takes ownership of the framework. |
|
68 |
|
69 @param aFramework Test framework |
|
70 */ |
|
71 void CImMobilityTestTls::AddFrameworkL(CImMobilityTestFramework& aFramework) |
|
72 { |
|
73 iFrameworkList.AppendL(&aFramework); |
|
74 } |
|
75 |
|
76 /** |
|
77 Removes a test framework from the list of frameworks and passes it back |
|
78 to the caller. The caller takes ownership of the framework. |
|
79 |
|
80 @param aMobilityManager Mobility manager associated with framework |
|
81 @param aLastOne Last framework has now been removed |
|
82 @return Test framework |
|
83 */ |
|
84 CImMobilityTestFramework* CImMobilityTestTls::RemoveFramework(CImMobilityManager& aMobilityManager, TBool& aLastOne) |
|
85 { |
|
86 CImMobilityTestFramework* framework = NULL; |
|
87 aLastOne = EFalse; |
|
88 |
|
89 for (TInt count = 0; count < iFrameworkList.Count(); ++count) |
|
90 { |
|
91 if (&(iFrameworkList[count]->MobilityManager()) == &aMobilityManager) |
|
92 { |
|
93 framework = iFrameworkList[count]; |
|
94 iFrameworkList.Remove(count); |
|
95 if (iFrameworkList.Count() == 0) |
|
96 { |
|
97 aLastOne = ETrue; |
|
98 } |
|
99 break; |
|
100 } |
|
101 } |
|
102 |
|
103 return framework; |
|
104 } |
|
105 |
|
106 /** |
|
107 Gets a test framework from the list of frameworks. |
|
108 |
|
109 @param aServiceId Service ID used as search key |
|
110 @return Test framework |
|
111 */ |
|
112 CImMobilityTestFramework* CImMobilityTestTls::GetFramework(TMsvId aServiceId) |
|
113 { |
|
114 for (TInt count = 0; count < iFrameworkList.Count(); ++count) |
|
115 { |
|
116 if (iFrameworkList[count]->ServiceId() == aServiceId) |
|
117 { |
|
118 return iFrameworkList[count]; |
|
119 } |
|
120 } |
|
121 |
|
122 return NULL; |
|
123 } |
|
124 |
|
125 /** |
|
126 Gets a test framework from the list of frameworks. |
|
127 |
|
128 @param aMobilityManager Mobility manager used as search key |
|
129 @return Test framework |
|
130 */ |
|
131 CImMobilityTestFramework* CImMobilityTestTls::GetFramework(CImMobilityManager& aMobilityManager) |
|
132 { |
|
133 for (TInt count = 0; count < iFrameworkList.Count(); ++count) |
|
134 { |
|
135 if (&(iFrameworkList[count]->MobilityManager()) == &aMobilityManager) |
|
136 { |
|
137 return iFrameworkList[count]; |
|
138 } |
|
139 } |
|
140 |
|
141 return NULL; |
|
142 } |
|
143 |
|
144 /** |
|
145 Gets a test framework from the list of frameworks. |
|
146 |
|
147 @param aProtocol MMobilityProtocolResp& used as search key |
|
148 @return Test framework |
|
149 */ |
|
150 CImMobilityTestFramework* CImMobilityTestTls::GetFramework(MMobilityProtocolResp& aProtocol) |
|
151 { |
|
152 for (TInt count = 0; count < iFrameworkList.Count(); ++count) |
|
153 { |
|
154 CImMobilityManager* man = &(iFrameworkList[count]->MobilityManager()); |
|
155 |
|
156 MMobilityProtocolResp* prot = static_cast<MMobilityProtocolResp*>(man); |
|
157 |
|
158 if (prot == &aProtocol) |
|
159 { |
|
160 return iFrameworkList[count]; |
|
161 } |
|
162 } |
|
163 |
|
164 return NULL; |
|
165 } |