|
1 /* |
|
2 * Copyright (c) 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 "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: XIMP Framework server test client implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "ximpbase.h" |
|
21 #include "ximpsrvtestclient.h" |
|
22 #include "ximpprocessstarter.h" |
|
23 #include "ximprootserverdefs.h" |
|
24 #include "ximpserverdefs.h" |
|
25 #include "prfwtestserverdefs.h" |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <s32mem.h> |
|
29 |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // RXIMPSrvRootClient::RXIMPSrvRootClient() |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 RXIMPSrvTestClient::RXIMPSrvTestClient() |
|
38 { |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // RXIMPSrvRootClient::Connect() |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 TInt RXIMPSrvTestClient::Connect() |
|
47 { |
|
48 TFileName fullExePath; |
|
49 XIMPProcessStarter::FullExePathForClienLocation( NRootSrv::NName::KExecutable, |
|
50 fullExePath ); |
|
51 |
|
52 TInt ret = XIMPProcessStarter::ConnectToServer( fullExePath, |
|
53 KNullDesC, |
|
54 NULL, |
|
55 *this, |
|
56 NRootSrv::NName::KSymbianServer, |
|
57 TVersion( NRootSrv::NVersion::KMajor, |
|
58 NRootSrv::NVersion::KMinor, |
|
59 NRootSrv::NVersion::KBuild ), |
|
60 NRootSrv::NRequest::KMsgSlotCount ); |
|
61 |
|
62 if ( ret == KErrNone ) |
|
63 { |
|
64 TIpcArgs msgArgs; |
|
65 ret = SendReceive( NTestSrv::NRequest::EInstantiateTestSession, msgArgs ); |
|
66 } |
|
67 |
|
68 return ret; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // RXIMPSrvContextClient::Connect() |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void RXIMPSrvTestClient::ConnectL( TUid aProtocolImpUid ) |
|
76 { |
|
77 // create the server name: "!XIMPCtxSrv9bde667a" |
|
78 HBufC* serverName = HBufC::NewLC( NXIMPSrv::NName::KSymbianServer().Length() + |
|
79 NXIMPSrv::NStartupParam::KProtocolUidMaxLen + |
|
80 1 ); |
|
81 |
|
82 serverName->Des().Copy( NXIMPSrv::NName::KSymbianServer ); |
|
83 serverName->Des().AppendNumFixedWidth( aProtocolImpUid.iUid, |
|
84 EHex, |
|
85 NXIMPSrv::NStartupParam::KProtocolUidMaxLen ); |
|
86 |
|
87 // Pass the UID to server side. |
|
88 // For security reasons it was not allowed to pass the complete |
|
89 // server name descriptor but just the UID part |
|
90 RArray< TXIMPProcessStartupParam > params; |
|
91 CleanupClosePushL( params ); |
|
92 |
|
93 TXIMPProcessStartupParam paramUid; |
|
94 paramUid.Set( NXIMPSrv::NStartupParam::KProtocolUidIndex, |
|
95 aProtocolImpUid.iUid ); |
|
96 |
|
97 User::LeaveIfError( params.Append( paramUid ) ); |
|
98 TArray< TXIMPProcessStartupParam > array = params.Array(); |
|
99 |
|
100 |
|
101 //Get path to correct exe to launch |
|
102 TFileName fullExePath; |
|
103 XIMPProcessStarter::FullExePathForClienLocation( NXIMPSrv::NName::KExecutable, |
|
104 fullExePath ); |
|
105 |
|
106 //Create a connection |
|
107 TInt ret = XIMPProcessStarter::ConnectToServer( fullExePath, |
|
108 KNullDesC, |
|
109 &array, |
|
110 *this, |
|
111 *serverName, |
|
112 TVersion( NXIMPSrv::NVersion::KMajor, |
|
113 NXIMPSrv::NVersion::KMinor, |
|
114 NXIMPSrv::NVersion::KBuild ), |
|
115 NXIMPSrv::NRequest::KMsgSlotCount ); |
|
116 User::LeaveIfError( ret ); |
|
117 CleanupStack::PopAndDestroy( 2, serverName ); // params, serverName |
|
118 |
|
119 //Mutate the server side session to correct type |
|
120 ret = SendReceive( NTestSrv::NRequest::EInstantiateTestSession ); |
|
121 User::LeaveIfError( ret ); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // RXIMPSrvRootClient::Close() |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void RXIMPSrvTestClient::Close() |
|
129 { |
|
130 RSessionBase::Close(); |
|
131 } |
|
132 |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // RXIMPSrvTestClient::SetAllocFailureL() |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void RXIMPSrvTestClient::SetAllocFailure( TInt aRate ) |
|
139 { |
|
140 TPckgBuf< TInt > rateBuf( aRate ); |
|
141 TIpcArgs msgArgs; |
|
142 msgArgs.Set( 0, &rateBuf ); |
|
143 |
|
144 SendReceive( NTestSrv::NRequest::ESetAllocFail, msgArgs ); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // RXIMPSrvRootClient::GetLastError() |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 NTestSrv::SErrorData RXIMPSrvTestClient::FetchErrorData() |
|
152 { |
|
153 NTestSrv::SErrorData errorData; |
|
154 TPckgBuf< NTestSrv::SErrorData > errorBuf( errorData ); |
|
155 TIpcArgs msgArgs; |
|
156 msgArgs.Set( 0, &errorBuf ); |
|
157 TInt retVal = SendReceive( NTestSrv::NRequest::EPrepareErrorData, msgArgs ); |
|
158 __ASSERT_ALWAYS( retVal >= 0, User::Panic( _L( "SendReceive failed" ), retVal ) ); |
|
159 errorData = errorBuf(); |
|
160 return errorData; |
|
161 // return GetData( NTestSrv::NRequest::EPrepareErrorData ); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // RXIMPSrvRootClient::GetDataL() |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 NTestSrv::SErrorData RXIMPSrvTestClient::GetData( TInt aMsg ) |
|
169 { |
|
170 /* TInt bufSize = SendReceive( aMsg ); |
|
171 __ASSERT_ALWAYS( bufSize == NTestSrv::KErrorDataSize, User::Panic( _L( "Wrong bufsize" ), KErrArgument ) ); |
|
172 |
|
173 NTestSrv::SErrorData errorData; |
|
174 TPckgBuf< NTestSrv::SErrorData > errorBuf( errorData ); |
|
175 TIpcArgs msgArgs; |
|
176 msgArgs.Set( 0, &errorBuf ); |
|
177 __ASSERT_ALWAYS( SendReceive( NTestSrv::NRequest::EFetchData, msgArgs ) >= 0, |
|
178 User::Panic( _L( "SendReceive failed" ) ) ); |
|
179 return errorData;*/ |
|
180 } |
|
181 |
|
182 |
|
183 // End of file |
|
184 |