0
|
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 "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 |
* @file
|
|
16 |
* This contains CTestServer2
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
/**
|
|
23 |
@prototype
|
|
24 |
@test
|
|
25 |
*/
|
|
26 |
|
|
27 |
// User Includes
|
|
28 |
#include "TestServer2.h"
|
|
29 |
|
|
30 |
TUint32 CTestServer2::Hash(const TDataDictionaryName& aName)
|
|
31 |
{
|
|
32 |
return DefaultHash::Des16(aName);
|
|
33 |
}
|
|
34 |
|
|
35 |
TBool CTestServer2::Identity(const TDataDictionaryName& aName1, const TDataDictionaryName& aName2)
|
|
36 |
{
|
|
37 |
return aName1.Compare(aName2)==0;
|
|
38 |
}
|
|
39 |
|
|
40 |
EXPORT_C CTestServer2::CTestServer2()
|
|
41 |
/*
|
|
42 |
* Constructor
|
|
43 |
*/
|
|
44 |
: CTestServer()
|
|
45 |
, iStore(Hash, Identity)
|
|
46 |
, iActiveScheduler(NULL)
|
|
47 |
{
|
|
48 |
}
|
|
49 |
|
|
50 |
EXPORT_C CTestServer2::~CTestServer2()
|
|
51 |
/*
|
|
52 |
* Destructor
|
|
53 |
*/
|
|
54 |
{
|
|
55 |
TDataIter iter(iStore);
|
|
56 |
iter.Reset();
|
|
57 |
for ( const TDataElement* data=iter.NextValue(); data!=NULL; data=iter.NextValue() )
|
|
58 |
{
|
|
59 |
data->iCleanupOperation(data->iAny);
|
|
60 |
}
|
|
61 |
iStore.Close();
|
|
62 |
|
|
63 |
if( iActiveScheduler )
|
|
64 |
{
|
|
65 |
delete iActiveScheduler;
|
|
66 |
iActiveScheduler=NULL;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
|
|
70 |
EXPORT_C void CTestServer2::ConstructL()
|
|
71 |
/*
|
|
72 |
* Second phase of construction
|
|
73 |
*/
|
|
74 |
{
|
|
75 |
RProcess handle = RProcess();
|
|
76 |
TParsePtrC serverName(handle.FileName());
|
|
77 |
CTestServer::ConstructL(serverName.Name());
|
|
78 |
}
|
|
79 |
|
|
80 |
// MTEFCallback::MSharedData implementation
|
|
81 |
EXPORT_C void CTestServer2::CreateActiveSchedulerL()
|
|
82 |
{
|
|
83 |
if( iActiveScheduler==NULL )
|
|
84 |
{
|
|
85 |
iActiveScheduler=new (ELeave) CActiveScheduler();
|
|
86 |
CActiveScheduler::Install(iActiveScheduler);
|
|
87 |
}
|
|
88 |
}
|
|
89 |
|
|
90 |
// MTEFCallback::MSharedData implementation
|
|
91 |
EXPORT_C void CTestServer2::DeleteActiveSchedulerL()
|
|
92 |
{
|
|
93 |
if( iActiveScheduler )
|
|
94 |
{
|
|
95 |
delete iActiveScheduler;
|
|
96 |
iActiveScheduler=NULL;
|
|
97 |
}
|
|
98 |
}
|
|
99 |
|
|
100 |
// MTEFCallback::MSharedData implementation
|
|
101 |
EXPORT_C TAny* CTestServer2::GetObjectAndOwnL(const TDesC& aName)
|
|
102 |
{
|
|
103 |
TDataElement* element=iStore.Find(aName);
|
|
104 |
TAny* ret=NULL;
|
|
105 |
|
|
106 |
if ( element != NULL )
|
|
107 |
{
|
|
108 |
ret=element->iAny;
|
|
109 |
iStore.Remove(aName);
|
|
110 |
}
|
|
111 |
else
|
|
112 |
{
|
|
113 |
User::Leave(KErrNotFound);
|
|
114 |
}
|
|
115 |
|
|
116 |
return ret;
|
|
117 |
}
|
|
118 |
|
|
119 |
// MTEFCallback::MSharedData implementation
|
|
120 |
EXPORT_C void CTestServer2::PutAndDisownL(const TDesC& aName, TAny* aAny, TCleanupOperation aCleanupOperation)
|
|
121 |
{
|
|
122 |
TDataElement* element=iStore.Find(aName);
|
|
123 |
// Ensure name does not already exist
|
|
124 |
if ( element!=NULL )
|
|
125 |
{
|
|
126 |
User::Leave(KErrAlreadyExists);
|
|
127 |
}
|
|
128 |
|
|
129 |
TDataIter iter(iStore);
|
|
130 |
iter.Reset();
|
|
131 |
for ( const TDataElement* data=iter.NextValue(); data!=NULL; data=iter.NextValue() )
|
|
132 |
{
|
|
133 |
if ( aAny == data->iAny )
|
|
134 |
{
|
|
135 |
User::Leave(KErrAlreadyExists);
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
TDataElement newElement={aAny, aCleanupOperation};
|
|
140 |
iStore.InsertL(aName, newElement);
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
// CTestServer implementation
|
|
145 |
EXPORT_C CTestStep* CTestServer2::CreateTestStep(const TDesC& /*aStepName*/)
|
|
146 |
{
|
|
147 |
CTestStep* step = NULL;
|
|
148 |
return step;
|
|
149 |
}
|