Update contrib.
2 * Copyright (c) 2007-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.
15 * Boilerplate code starts up server and exits the process when
16 * the server has stopped.
25 #include <scs/scsserver.h>
28 NONSHARABLE_CLASS(CSystemActiveScheduler) : public CActiveScheduler
30 virtual void Error(TInt aError) const;
33 void CSystemActiveScheduler::Error(TInt aError) const
35 // Ignore the error and continue...
36 RDebug::Printf("SCS- Active object failed with code %d - IGNORED\n", aError);
39 static void RunServerL(TScsServerFactory aServerFactoryLC)
41 Allocate and start the session counting server.
43 @param aServerFactoryLC Factory function defined in the implementation
44 EXE, which allocates an instance of the server object
45 and puts it on the cleanup stack.
48 CActiveScheduler* as = new(ELeave) CSystemActiveScheduler;
49 CleanupStack::PushL(as);
50 CActiveScheduler::Install(as);
52 // the server is started when it is allocated
53 (void) aServerFactoryLC();
55 // tell launching process the server has started successfully
56 RProcess::Rendezvous(KErrNone);
58 CActiveScheduler::Start();
60 // the active scheduler has been stopped here because there have
61 // been no current sessions for the shutdown period.
62 CleanupStack::PopAndDestroy(2, as);
65 EXPORT_C TInt StartScsServer(TScsServerFactory aServerFactoryLC)
67 This function must be called from the server executable's E32Main function.
68 It sets up a cleanup stack and active scheduler before starting the server.
70 If the server is started successfully then this function does not return
71 until the server shuts down.
73 @param aServerFactoryLC Factory function defined in the implementation
74 EXE, which allocates an instance of the server object
75 and puts it on the cleanup stack.
76 @return Symbian OS error code. KErrNone indicates success,
77 and any other value indicates failure.
82 // allocating a cleanup stack also installs it
83 CTrapCleanup* tc = CTrapCleanup::New();
87 TRAPD(r, RunServerL(aServerFactoryLC));