localisation/apparchitecture/apserv/APSSTART.CPP
branchSymbian3
changeset 57 b8d18c84f71c
parent 6 c108117318cb
equal deleted inserted replaced
56:aa99f2208aad 57:b8d18c84f71c
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     7 //
     8 // Initial Contributors:
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
     9 // Nokia Corporation - initial contribution.
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // The main startup of the AppArc server
    14 // The main startup of the AppArc server
    15 // 
    15 // 
       
    16 // apsstart.cpp
    16 //
    17 //
    17 
    18 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    18 #include <apsserv.h>
    19 #if !defined(__APA_INTERNAL_H__)
       
    20 #include "apainternal.h"
       
    21 #endif
       
    22 #include "apaidpartner.h"
       
    23 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    24 #include "apsserv.h"
    19 #include <fbs.h>
    25 #include <fbs.h>
    20 
    26 
    21 #include "APASVST.H"
    27 #include "APASVST.H"
    22 #include "APAFLREC.H"
    28 #include "APAFLREC.H"
    23 
    29 
    50 static void CleanupRFbsSession(TAny*)
    56 static void CleanupRFbsSession(TAny*)
    51 	{
    57 	{
    52 	RFbsSession::Disconnect();
    58 	RFbsSession::Disconnect();
    53 	}
    59 	}
    54 
    60 
    55 static void RunServerL(MApaAppStarter* aAppStarter)
    61 static void RunServerL()
    56 //
    62 //
    57 // Perform all server initialisation, in particular creation of the
    63 // Perform all server initialisation, in particular creation of the
    58 // scheduler and server and then run the scheduler
    64 // scheduler and server and then run the scheduler
    59 //
    65 //
    60 	{
    66 	{
    61 	MApaAppStarter* appStarter = aAppStarter;
       
    62 	// create and install the active scheduler we need
    67 	// create and install the active scheduler we need
    63 	CSvActiveScheduler::NewLC();
    68 	CSvActiveScheduler::NewLC();
       
    69 
    64 	// create a RFbsSession
    70 	// create a RFbsSession
    65 	User::LeaveIfError(RFbsSession::Connect());
    71 	User::LeaveIfError(RFbsSession::Connect());
    66 	CleanupStack::PushL(TCleanupItem(CleanupRFbsSession, NULL));
    72 	CleanupStack::PushL(TCleanupItem(CleanupRFbsSession, NULL));
    67 	//
    73 
    68 	// create the server (leave it on the cleanup stack)
    74 	// create the server (leave it on the cleanup stack)
    69 	CApaAppListServer* appListServer = CApaAppListServer::NewL(appStarter);
    75 	CApaAppArcServer* appArcServer = CApaAppArcServer::NewL();
    70 	CleanupStack::PushL(appListServer);
    76 	CleanupStack::PushL(appArcServer);
    71 	//
    77 
    72 	// Initialisation complete, now signal the client
    78 	// Initialisation complete, now signal the client
    73 #ifdef APA_SERVER_IN_THREAD
    79 	RProcess::Rendezvous(KErrNone);
    74 	RThread::Rendezvous(KErrNone);
    80 
    75 #else
       
    76 	if(aAppStarter)
       
    77 		{
       
    78 		// Launching in a thread within an existing process.
       
    79 		RThread::Rendezvous(KErrNone);
       
    80 		}
       
    81 	else
       
    82 		{
       
    83 		RProcess::Rendezvous(KErrNone);
       
    84 		}
       
    85 #endif
       
    86 	//
       
    87 	// Ready to run
    81 	// Ready to run
    88 	CActiveScheduler::Start();
    82 	CActiveScheduler::Start();
    89 	//
    83 
    90 	// Cleanup the server, RFbsSession and scheduler
    84 	// Cleanup the server, RFbsSession and scheduler
    91 	CleanupStack::PopAndDestroy(3);
    85 	CleanupStack::PopAndDestroy(3);
    92 	}
    86 	}
    93 
    87 
    94 static TInt RunServer(MApaAppStarter* aAppStarter)
    88 static TInt RunServer()
    95 //
    89 //
    96 // Main entry-point for the server thread
    90 // Main entry-point for the server thread
    97 //
    91 //
    98 	{
    92 	{
    99 	__UHEAP_MARK;
    93 	__UHEAP_MARK;
   105 		{
    99 		{
   106 		CTrapCleanup* cleanup=CTrapCleanup::New();
   100 		CTrapCleanup* cleanup=CTrapCleanup::New();
   107 		r=KErrNoMemory;
   101 		r=KErrNoMemory;
   108 		if (cleanup)
   102 		if (cleanup)
   109 			{
   103 			{
   110 			TRAP(r,RunServerL(aAppStarter));
   104 			TRAP(r,RunServerL());
   111 			REComSession::FinalClose();
   105 			REComSession::FinalClose();
   112 			delete cleanup;
   106 			delete cleanup;
   113 			}
   107 			}
   114 		}
   108 		}
   115 	//
   109 	//
   119 
   113 
   120 /**
   114 /**
   121 ApaServThreadStart
   115 ApaServThreadStart
   122 
   116 
   123 @internalTechnology
   117 @internalTechnology
       
   118 @released
   124 */
   119 */
   125 EXPORT_C TInt ApaServThreadStart(TAny* aAppStarter)
   120 EXPORT_C TInt ApaServThreadStart(TAny* /*aUnused*/)
   126 //
   121 //
   127 // thread entry-point function.
   122 // thread entry-point function.
   128 //
   123 //
   129 	{
   124 	{
   130 	MApaAppStarter* appStarter = reinterpret_cast<MApaAppStarter*>(aAppStarter);
   125 	return RunServer();
   131 	return RunServer(appStarter);
       
   132 	}
   126 	}