sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "T_SerialDriverServer.h"
|
sl@0
|
19 |
#include "T_RBusDevCommData.h"
|
sl@0
|
20 |
#include "T_TCommCapsV03Data.h"
|
sl@0
|
21 |
#include "T_TCommConfigV02Data.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
/*@{*/
|
sl@0
|
24 |
_LIT(KT_RBusDevComm, "RBusDevComm");
|
sl@0
|
25 |
_LIT(KT_TCommCapsV01, "TCommCapsV01");
|
sl@0
|
26 |
_LIT(KT_TCommCapsV02, "TCommCapsV02");
|
sl@0
|
27 |
_LIT(KT_TCommCapsV03, "TCommCapsV03");
|
sl@0
|
28 |
_LIT(KT_TCommConfigV01, "TCommConfigV01");
|
sl@0
|
29 |
_LIT(KT_TCommConfigV02, "TCommConfigV02");
|
sl@0
|
30 |
/*@}*/
|
sl@0
|
31 |
|
sl@0
|
32 |
CT_SerialDriverServer* CT_SerialDriverServer::NewL()
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
* @return - Instance of the test server
|
sl@0
|
35 |
* Same code for Secure and non-secure variants
|
sl@0
|
36 |
* Called inside the MainL() function to create and start the
|
sl@0
|
37 |
* CTestServer derived server.
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
{
|
sl@0
|
40 |
CT_SerialDriverServer* server = new (ELeave) CT_SerialDriverServer();
|
sl@0
|
41 |
CleanupStack::PushL(server);
|
sl@0
|
42 |
server->ConstructL();
|
sl@0
|
43 |
CleanupStack::Pop(server);
|
sl@0
|
44 |
return server;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
|
sl@0
|
48 |
LOCAL_C void MainL()
|
sl@0
|
49 |
/**
|
sl@0
|
50 |
* Secure variant
|
sl@0
|
51 |
* Much simpler, uses the new Rendezvous() call to sync with the client
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
{
|
sl@0
|
54 |
#if (defined __DATA_CAGING__)
|
sl@0
|
55 |
RProcess().DataCaging(RProcess::EDataCagingOn);
|
sl@0
|
56 |
RProcess().SecureApi(RProcess::ESecureApiOn);
|
sl@0
|
57 |
#endif
|
sl@0
|
58 |
CActiveScheduler* sched=NULL;
|
sl@0
|
59 |
sched=new(ELeave) CActiveScheduler;
|
sl@0
|
60 |
CActiveScheduler::Install(sched);
|
sl@0
|
61 |
CT_SerialDriverServer* server = NULL;
|
sl@0
|
62 |
|
sl@0
|
63 |
// Create the CTestServer derived server
|
sl@0
|
64 |
TRAPD(err,server = CT_SerialDriverServer::NewL());
|
sl@0
|
65 |
if(!err)
|
sl@0
|
66 |
{
|
sl@0
|
67 |
// Sync with the client and enter the active scheduler
|
sl@0
|
68 |
RProcess::Rendezvous(KErrNone);
|
sl@0
|
69 |
sched->Start();
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
delete server;
|
sl@0
|
73 |
delete sched;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
|
sl@0
|
77 |
GLDEF_C TInt E32Main()
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
* @return - Standard Epoc error code on process exit
|
sl@0
|
80 |
* Secure variant only
|
sl@0
|
81 |
* Process entry point. Called by client using RProcess API
|
sl@0
|
82 |
*/
|
sl@0
|
83 |
{
|
sl@0
|
84 |
__UHEAP_MARK;
|
sl@0
|
85 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
86 |
if(cleanup == NULL)
|
sl@0
|
87 |
{
|
sl@0
|
88 |
return KErrNoMemory;
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
#if (defined TRAP_IGNORE)
|
sl@0
|
92 |
TRAP_IGNORE(MainL());
|
sl@0
|
93 |
#else
|
sl@0
|
94 |
TRAPD(err,MainL());
|
sl@0
|
95 |
#endif
|
sl@0
|
96 |
|
sl@0
|
97 |
delete cleanup;
|
sl@0
|
98 |
__UHEAP_MARKEND;
|
sl@0
|
99 |
return KErrNone;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
CDataWrapper* CT_SerialDriverServer::CT_SerialDriverBlock::CreateDataL(const TDesC& aData)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
CDataWrapper* wrapper=NULL;
|
sl@0
|
105 |
|
sl@0
|
106 |
if( aData==KT_RBusDevComm() )
|
sl@0
|
107 |
{
|
sl@0
|
108 |
wrapper=CT_RBusDevCommData::NewL();
|
sl@0
|
109 |
}
|
sl@0
|
110 |
else if ( aData==KT_TCommCapsV01 )
|
sl@0
|
111 |
{
|
sl@0
|
112 |
wrapper=new (ELeave) CT_TCommCapsV01Data();
|
sl@0
|
113 |
}
|
sl@0
|
114 |
else if ( aData==KT_TCommCapsV02 )
|
sl@0
|
115 |
{
|
sl@0
|
116 |
wrapper=new (ELeave) CT_TCommCapsV02Data();
|
sl@0
|
117 |
}
|
sl@0
|
118 |
else if ( aData==KT_TCommCapsV03 )
|
sl@0
|
119 |
{
|
sl@0
|
120 |
wrapper=new (ELeave) CT_TCommCapsV03Data();
|
sl@0
|
121 |
}
|
sl@0
|
122 |
else if ( aData==KT_TCommConfigV01 )
|
sl@0
|
123 |
{
|
sl@0
|
124 |
wrapper=new (ELeave) CT_TCommConfigV01Data();
|
sl@0
|
125 |
}
|
sl@0
|
126 |
else if ( aData==KT_TCommConfigV02 )
|
sl@0
|
127 |
{
|
sl@0
|
128 |
wrapper=new (ELeave) CT_TCommConfigV02Data();
|
sl@0
|
129 |
}
|
sl@0
|
130 |
|
sl@0
|
131 |
return wrapper;
|
sl@0
|
132 |
}
|