examples/Base/IPC/secureserver/secureserver.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // Contains the implementation of functions described in the CSecureServer class.
00015 //
00016 
00017 
00018 
00022 #include "secureclientandserver.h"
00023 #include "secureserver.h"
00024 
00034 TInt CSecureServer::ThreadFunction(TAny* )
00035         {
00036         TInt err;
00037         CTrapCleanup* cleanup = CTrapCleanup::New();
00038         if (cleanup == NULL)
00039                 {
00040                 PanicServer(ECreateTrapCleanup);
00041                 }
00042 
00043         CActiveScheduler* pScheduler=new CActiveScheduler;
00044         __ASSERT_ALWAYS(pScheduler,PanicServer(EMainSchedulerError));
00045         CActiveScheduler::Install(pScheduler);
00046 
00047         CSecureServer* pServer = NULL;
00048         TRAP(err,pServer = CSecureServer::NewL(EPriorityStandard));
00049         __ASSERT_ALWAYS(!err,CSecureServer::PanicServer(EServerCreateServer));
00050 
00051         err = pServer->Start(KSecureServerName);
00052         if (err != KErrNone)
00053                 {
00054                 CSecureServer::PanicServer(EServerStartServer);
00055                 }
00056 
00057         RThread::Rendezvous(KErrNone);
00058         CActiveScheduler::Start();
00059 
00060         delete pServer;
00061         delete pScheduler;
00062         delete cleanup;
00063 
00064         return KErrNone;
00065         }
00066 
00074 EXPORT_C TInt StartThread(RThread& aServerThread)
00075         {
00076         TInt res=KErrNone;
00077         TFindServer findCountServer(KSecureServerName);
00078         TFullName   name;
00079         if (findCountServer.Next(name)!=KErrNone)
00080                 {
00081                         res=aServerThread.Create(KSecureServerName,
00082                         CSecureServer::ThreadFunction,
00083                         KDefaultStackSize,
00084                         KDefaultHeapSize,
00085                         KDefaultHeapSize,
00086                         NULL
00087                         );
00088                 if (res==KErrNone)
00089                         {
00090                         TRequestStatus rendezvousStatus;
00091                         aServerThread.SetPriority(EPriorityNormal);
00092                         aServerThread.Rendezvous(rendezvousStatus);
00093                         aServerThread.Resume();
00094                         User::WaitForRequest(rendezvousStatus);
00095                         }
00096                 else
00097                         {
00098                         aServerThread.Close();
00099                         }
00100                 }
00101         return res;
00102         }

Generated by  doxygen 1.6.2