|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "t_lbsclientserver.h" |
|
20 #include "t_rpositionerdata.h" |
|
21 #include "t_rpositionserverdata.h" |
|
22 |
|
23 _LIT(KT_RPositioner, "RPositioner"); |
|
24 _LIT(KT_RPositionServer, "RPositionServer"); |
|
25 |
|
26 /** |
|
27 * Same code for Secure and non-secure variants |
|
28 * Called inside the MainL() function to create and start the |
|
29 * CTestServer derived server. |
|
30 * @return - Instance of the test server |
|
31 */ |
|
32 CT_LbsClientServer* CT_LbsClientServer::NewL() |
|
33 { |
|
34 CT_LbsClientServer* server = new (ELeave) CT_LbsClientServer(); |
|
35 CleanupStack::PushL(server); |
|
36 server->ConstructL(); |
|
37 CleanupStack::Pop(server); |
|
38 return server; |
|
39 } |
|
40 |
|
41 /** |
|
42 * Secure variant |
|
43 * Much simpler, uses the new Rendezvous() call to sync with the client |
|
44 */ |
|
45 LOCAL_C void MainL() |
|
46 { |
|
47 #if (defined __DATA_CAGING__) |
|
48 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
49 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
50 #endif |
|
51 CActiveScheduler* sched = NULL; |
|
52 sched = new(ELeave) CActiveScheduler; |
|
53 CActiveScheduler::Install(sched); |
|
54 CT_LbsClientServer* server = NULL; |
|
55 |
|
56 // Create the CTestServer derived server |
|
57 TRAPD(err, server = CT_LbsClientServer::NewL()); |
|
58 if(!err) |
|
59 { |
|
60 // Sync with the client and enter the active scheduler |
|
61 RProcess::Rendezvous(KErrNone); |
|
62 sched->Start(); |
|
63 } |
|
64 |
|
65 delete server; |
|
66 delete sched; |
|
67 } |
|
68 |
|
69 /** |
|
70 * Secure variant only |
|
71 * Process entry point. Called by client using RProcess API |
|
72 * @return - Standard Epoc error code on process exit |
|
73 */ |
|
74 GLDEF_C TInt E32Main() |
|
75 { |
|
76 __UHEAP_MARK; |
|
77 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
78 if(cleanup == NULL) |
|
79 { |
|
80 return KErrNoMemory; |
|
81 } |
|
82 |
|
83 #if (defined TRAP_IGNORE) |
|
84 TRAP_IGNORE(MainL()); |
|
85 #else |
|
86 TRAPD(err,MainL()); |
|
87 #endif |
|
88 |
|
89 delete cleanup; |
|
90 __UHEAP_MARKEND; |
|
91 return KErrNone; |
|
92 } |
|
93 |
|
94 CDataWrapper* CT_LbsClientServer::CT_LbsBlock::CreateDataL(const TDesC& aData) |
|
95 { |
|
96 CDataWrapper* wrapper = NULL; |
|
97 |
|
98 if( KT_RPositioner() == aData ) |
|
99 { |
|
100 wrapper = CT_RPositionerData::NewL(); |
|
101 } |
|
102 else if (KT_RPositionServer() == aData) |
|
103 { |
|
104 wrapper = CT_RPositionServerData::NewL(); |
|
105 } |
|
106 |
|
107 return wrapper; |
|
108 } |