0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 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: Set and cancel async calls and write logs
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <stifitemparser.h>
|
|
22 |
#include "notify.h"
|
|
23 |
#include "notifyhandler.h"
|
|
24 |
|
|
25 |
|
|
26 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
27 |
|
|
28 |
// -----------------------------------------------------------------------------
|
|
29 |
// CSimAtkNotify::CSimAtkNotify
|
|
30 |
// C++ default constructor can NOT contain any code, that
|
|
31 |
// might leave.
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
CSimAtkNotify::CSimAtkNotify
|
|
35 |
(
|
|
36 |
CTestModuleIf& aTestModuleIf
|
|
37 |
) : CScriptBase( aTestModuleIf )
|
|
38 |
{
|
|
39 |
iNotifyHandler = NULL;
|
|
40 |
iCore = NULL;
|
|
41 |
}
|
|
42 |
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
// CSimAtkNotify::ConstructL
|
|
45 |
// Symbian 2nd phase constructor can leave.
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
void CSimAtkNotify::ConstructL()
|
|
49 |
{
|
|
50 |
iLog = CStifLogger::NewL( KCoreLogPath, KCoreLogFile,
|
|
51 |
CStifLogger::ETxt, CStifLogger::EFile, ETrue );
|
|
52 |
|
|
53 |
iNotifyHandler = CSimAtkNotifyHandler::NewL( this, iLog );
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
// CSimAtkNotify::NewL
|
|
58 |
// Two-phased constructor.
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CSimAtkNotify* CSimAtkNotify::NewL
|
|
62 |
(
|
|
63 |
CTestModuleIf& aTestModuleIf
|
|
64 |
)
|
|
65 |
{
|
|
66 |
CSimAtkNotify* self = new (ELeave) CSimAtkNotify( aTestModuleIf );
|
|
67 |
CleanupStack::PushL( self );
|
|
68 |
self->ConstructL();
|
|
69 |
CleanupStack::Pop();
|
|
70 |
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
// CSimAtkNotify::~CSimAtkNotify
|
|
76 |
// Destructor
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
CSimAtkNotify::~CSimAtkNotify()
|
|
80 |
{
|
|
81 |
delete iNotifyHandler;
|
|
82 |
iNotifyHandler = NULL;
|
|
83 |
|
|
84 |
delete iLog;
|
|
85 |
iLog = NULL;
|
|
86 |
|
|
87 |
iCore = NULL;
|
|
88 |
}
|
|
89 |
|
|
90 |
// -----------------------------------------------------------------------------
|
|
91 |
// CSimAtkNotify::CSimAtkCore
|
|
92 |
// Return pointer to core class
|
|
93 |
// -----------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
CSimAtkCore* CSimAtkNotify::SimAtkCore()
|
|
96 |
{
|
|
97 |
return iCore;
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
// CSimAtkNotify::UseObjectAddress
|
|
103 |
// Notifies and cancels notifys according to script
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
TInt CSimAtkNotify::UseObjectAddress
|
|
107 |
(
|
|
108 |
CStifItemParser& aItem
|
|
109 |
)
|
|
110 |
{
|
|
111 |
TPtrC objectName;
|
|
112 |
TInt ret ( KErrNone );
|
|
113 |
|
|
114 |
// Find tag
|
|
115 |
ret = aItem.GetString( _L( "UseObjectAddress" ), objectName );
|
|
116 |
|
|
117 |
CScriptBase* script = GetTestObject( objectName );
|
|
118 |
|
|
119 |
// This must be done every time GetTestObject is just called
|
|
120 |
if ( NULL == script )
|
|
121 |
{
|
|
122 |
iLog->Log( _L( "CSimAtkNotify::UseObjectAddresL \
|
|
123 |
- Script == NULL" ) );
|
|
124 |
ret = KErrGeneral;
|
|
125 |
}
|
|
126 |
else
|
|
127 |
{
|
|
128 |
iLog->Log( _L ( "CSimAtkNotify::UseObjectAddressL \
|
|
129 |
- Start to cast objects " ) );
|
|
130 |
iCore = reinterpret_cast <CSimAtkCore*>( script );
|
|
131 |
|
|
132 |
// Identify the type of notify
|
|
133 |
TPtrC notifyPtr;
|
|
134 |
ret = aItem.GetNextString( notifyPtr );
|
|
135 |
|
|
136 |
if ( KErrNone == ret )
|
|
137 |
{
|
|
138 |
// Potential notify string found. Identify the notify or
|
|
139 |
// cancellation and map it to an ipc.
|
|
140 |
|
|
141 |
TSatIpc notifyIpc;
|
|
142 |
TBool isNotify = EFalse;
|
|
143 |
|
|
144 |
notifyIpc = iCore->MapStringToIpc( notifyPtr, isNotify );
|
|
145 |
|
|
146 |
if ( isNotify && ( notifyIpc != KErrNotFound ) )
|
|
147 |
{
|
|
148 |
iNotifyHandler->SetNotify( notifyIpc );
|
|
149 |
ret = iCore->Notify( iNotifyHandler->Status(), notifyIpc );
|
|
150 |
|
|
151 |
if ( KErrNone == ret )
|
|
152 |
{
|
|
153 |
iLog->Log( _L ( "CSimAtkNotify::UseObjectAddressL \
|
|
154 |
Notify %S " ), ¬ifyPtr );
|
|
155 |
|
|
156 |
iNotifyHandler->Activate();
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
iLog->Log( _L ( "CSimAtkNotify::UseObjectAddressL \
|
|
161 |
Notifying of %S failed! " ), ¬ifyPtr );
|
|
162 |
|
|
163 |
iNotifyHandler->Cancel();
|
|
164 |
}
|
|
165 |
}
|
|
166 |
else if ( EFalse == isNotify )// This is cancellation of notify
|
|
167 |
{
|
|
168 |
iNotifyHandler->Cancel();
|
|
169 |
iLog->Log( _L( "CSimAtkNotify::UseObjectAddressL \
|
|
170 |
- object Canceled " ) );
|
|
171 |
}
|
|
172 |
else
|
|
173 |
{
|
|
174 |
iLog->Log( _L( "CSimAtkNotify::UseObjectAddressL \
|
|
175 |
- Unsupported notify request received! Aborting..." ) );
|
|
176 |
iNotifyHandler->Cancel();
|
|
177 |
|
|
178 |
ret = KErrNotFound;
|
|
179 |
}
|
|
180 |
|
|
181 |
iLog->Log( _L( "CSimAtkNotify::UseObjectAddressL \
|
|
182 |
Method done " ) );
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
return ret;
|
|
187 |
}
|
|
188 |
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
// CSimAtkNotify::RunMethodL
|
|
191 |
// Run specified method. Contains also table of test mothods and their names.
|
|
192 |
// -----------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
TInt CSimAtkNotify::RunMethodL(
|
|
195 |
CStifItemParser& aItem )
|
|
196 |
{
|
|
197 |
TInt count = 0;
|
|
198 |
const TStifFunctionInfo* functions = RunMethodCases( count );
|
|
199 |
|
|
200 |
return CScriptBase::RunInternalL( functions, count, aItem );
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
// CSimAtkNotify::RunInternalL
|
|
205 |
// Run specified method from derived class or core class.
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
TInt CSimAtkNotify::RunInternalL
|
|
209 |
(
|
|
210 |
TStifFunctionInfo const aFunctions[], // Function table
|
|
211 |
TInt aCount, // Size of function table
|
|
212 |
CStifItemParser& aItem // reference to parser
|
|
213 |
)
|
|
214 |
{
|
|
215 |
iLog->Log( _L( "CSimAtkNotify::RunInternalL " ) );
|
|
216 |
TInt count = 0;
|
|
217 |
const TStifFunctionInfo* functions = RunMethodCases( count );
|
|
218 |
|
|
219 |
TInt total = count + aCount;
|
|
220 |
|
|
221 |
TUint8* tmp = new( total * sizeof( TStifFunctionInfo ) ) TUint8;
|
|
222 |
User::LeaveIfNull( tmp );
|
|
223 |
|
|
224 |
TStifFunctionInfo* allFuncs = ( TStifFunctionInfo* ) tmp;
|
|
225 |
|
|
226 |
Mem::Copy( &allFuncs[0], aFunctions,
|
|
227 |
aCount * sizeof( TStifFunctionInfo ) );
|
|
228 |
Mem::Copy( &allFuncs[aCount], functions,
|
|
229 |
count * sizeof( TStifFunctionInfo ) );
|
|
230 |
|
|
231 |
TInt ret = CScriptBase::RunInternalL( allFuncs, total, aItem );
|
|
232 |
|
|
233 |
delete tmp;
|
|
234 |
|
|
235 |
return ret;
|
|
236 |
}
|
|
237 |
|
|
238 |
// -----------------------------------------------------------------------------
|
|
239 |
// CSimAtkNotify::RunMethodCases
|
|
240 |
// Return function table.
|
|
241 |
// -----------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
const TStifFunctionInfo* CSimAtkNotify::RunMethodCases( TInt& aCount )
|
|
244 |
{
|
|
245 |
static TStifFunctionInfo const KFunctions[] =
|
|
246 |
{
|
|
247 |
// Copy this line for every implemented function.
|
|
248 |
// First string is the function name used in TestScripter script file.
|
|
249 |
// Second is the actual implementation member function.
|
|
250 |
ENTRY( "UseObjectAddress", CSimAtkNotify::UseObjectAddress ),
|
|
251 |
};
|
|
252 |
|
|
253 |
aCount = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
|
|
254 |
|
|
255 |
return KFunctions;
|
|
256 |
}
|
|
257 |
|
|
258 |
|
|
259 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
260 |
|
|
261 |
// -----------------------------------------------------------------------------
|
|
262 |
// LibEntryL is a polymorphic Dll entry point.
|
|
263 |
// Returns: CScriptBase: New CScriptBase derived object
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
EXPORT_C CScriptBase* LibEntryL
|
|
267 |
(
|
|
268 |
CTestModuleIf& aTestModuleIf // Backpointer to STIF Test Framework
|
|
269 |
)
|
|
270 |
{
|
|
271 |
return ( CScriptBase* ) CSimAtkNotify::NewL( aTestModuleIf );
|
|
272 |
}
|
|
273 |
|
|
274 |
// -----------------------------------------------------------------------------
|
|
275 |
// E32Dll is a DLL entry point function.
|
|
276 |
// Returns: KErrNone
|
|
277 |
// -----------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
#ifndef EKA2 // Hide Dll entry point to EKA2
|
|
280 |
GLDEF_C TInt E32Dll
|
|
281 |
(
|
|
282 |
TDllReason /*aReason*/ // Reason code
|
|
283 |
)
|
|
284 |
{
|
|
285 |
return(KErrNone);
|
|
286 |
}
|
|
287 |
#endif // EKA2
|
|
288 |
|
|
289 |
// End of File
|