os/security/cryptoservices/filebasedcertificateandkeystores/source/generic/client/clientsession.cpp
Update contrib.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "clientsession.h"
22 #include "clientutils.h"
23 #include "fstokenservername.h"
25 #ifdef SYMBIAN_AUTH_SERVER
32 #endif // SYMBIAN_AUTH_SERVER
34 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\
35 // Tokentype session class for file based certificate store
36 // Connects and passes messages to the file store tokentype server
37 // Coded specifically for file store token type
38 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\
40 _LIT(KFSTokenServerImg,"fstokenserver");
41 #ifdef SYMBIAN_AUTH_SERVER
43 _LIT(KFSNewTokenServerImg,"fstokenserver_useauth");
45 #endif // SYMBIAN_AUTH_SERVER
47 RFileStoreClientSession::RFileStoreClientSession()
50 TInt RFileStoreClientSession::SendRequest(TFSTokenMessages aRequest, const TIpcArgs& aArgs) const
52 return SendReceive(aRequest, aArgs);
55 void RFileStoreClientSession::SendAsyncRequest(TFSTokenMessages aRequest, const TIpcArgs& aArgs, TRequestStatus* aStatus) const
57 __ASSERT_ALWAYS(aStatus, FSTokenPanic(EBadArgument));
61 *aStatus = KRequestPending;
62 SendReceive(aRequest, aArgs, *aStatus);
67 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\
68 // Client-server startup code
69 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\
71 static TInt StartServer(); // Forward declaration
73 // Connect to the server, attempting to start it if necessary
76 #ifdef SYMBIAN_AUTH_SERVER
79 static bool UseAuthServer(void);
81 #endif // SYMBIAN_AUTH_SERVER
84 TInt RFileStoreClientSession::Connect(ETokenEnum aToken)
86 // The version is made up of three pieces of information:
87 // 1. iMajor - The token we want to talk to
88 // 2. iMinor - The protocol version number
90 TVersion version(aToken, KFSProtolVersion, 0);
96 #ifdef SYMBIAN_AUTH_SERVER
100 err = CreateSession(KFSNewTokenServerName, version, 1);
104 #endif // SYMBIAN_AUTH_SERVER
106 err = CreateSession(KFSTokenServerName, version, 1);
109 if (err!=KErrNotFound && err!=KErrServerTerminated)
114 if (err!=KErrNone && err!=KErrAlreadyExists)
119 #ifdef SYMBIAN_AUTH_SERVER
122 /*static*/ bool UseAuthServer(void)
124 bool useAuthServer = false;
127 // For the emulator allow the constant to be patched via epoc.ini
128 UserSvr::HalFunction(EHalGroupEmulator, EEmulatorHalIntProperty,
129 (TAny*)"KKeyStoreUseAuthServer", &useAuth); // read emulator property (if present)
132 useAuthServer = true;
134 return useAuthServer;
137 #endif // SYMBIAN_AUTH_SERVER
141 // Server startup is different for WINS in EKA1 mode ONLY (lack of process
142 // emulation - we load the library in this instance
143 const TUidType serverUid(KNullUid, KNullUid, KUidFSTokenServer);
146 TInt error = KErrNone;
148 #ifdef SYMBIAN_AUTH_SERVER
152 error = server.Create(KFSNewTokenServerImg, KNullDesC, serverUid);
156 #endif // SYMBIAN_AUTH_SERVER
158 error = server.Create(KFSTokenServerImg, KNullDesC, serverUid);
161 if (error != KErrNone)
166 // Synchronise with the process to make sure it hasn't died straight away
168 server.Rendezvous(stat);
169 if (stat != KRequestPending)
171 // logon failed - server is not yet running, so cannot have terminated
172 server.Kill(0); // Abort startup
176 // logon OK - start the server
180 // Wait to synchronise with server - if it dies in the meantime, it
181 // also gets completed
182 User::WaitForRequest(stat);
184 // We can't use the 'exit reason' if the server panicked as this
185 // is the panic 'reason' and may be '0' which cannot be distinguished
187 error = (server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();