messagingfw/msgsrvnstore/server/src/MSVSTART.CPP
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <e32std.h>
       
    17 #include <basched.h>
       
    18 
       
    19 #include "MSVSTD.H"
       
    20 #include "MSERVER.H"
       
    21 #include "MSVSERV.H"
       
    22 #include "MSVPANIC.H"
       
    23 #include "MSVENTRY.H"
       
    24 
       
    25 _LIT(KMsvServerPanicString, "MSGS");
       
    26 
       
    27 //**********************************
       
    28 // Single exported function
       
    29 //**********************************
       
    30 
       
    31 EXPORT_C TInt StartMessageServer(TAny* /*anArg*/)
       
    32 //
       
    33 // The message server thread function
       
    34 //
       
    35 	{
       
    36 	TBuf<32> name(KMsvServerName);
       
    37 		RProcess().RenameMe(name);
       
    38 	User::RenameThread(name);
       
    39 	__UHEAP_MARK;
       
    40 
       
    41 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    42 	
       
    43 	if(!cleanup) 
       
    44     	{ 
       
    45    		return KErrNoMemory; 
       
    46         } 
       
    47 
       
    48 
       
    49 	CBaActiveScheduler *pA=new CBaActiveScheduler;
       
    50 	__ASSERT_ALWAYS(pA!=NULL,PanicServer(EMainSchedulerError1));
       
    51 	CActiveScheduler::Install(pA);
       
    52 
       
    53 	CMsvServer* server=NULL;
       
    54 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
    55 	TRAPD(err, server = CMsvServer::NewL(ETrue));
       
    56 #else
       
    57 	TRAPD(err, server = CMsvServer::NewL(EFalse));
       
    58 #endif
       
    59 
       
    60 	if( err != KErrNone )
       
    61 		return err;
       
    62 	
       
    63 	RProcess::Rendezvous(KErrNone);
       
    64 
       
    65 	CActiveScheduler::Start();
       
    66 
       
    67 	// finished
       
    68 	delete server;
       
    69 	CActiveScheduler::Install(NULL);
       
    70 	delete pA;
       
    71 	delete cleanup;
       
    72 
       
    73 
       
    74 	__UHEAP_MARKEND;
       
    75 
       
    76 	return KErrNone;
       
    77 	}
       
    78 
       
    79 // Create Message Server and return a server entry owned by caller
       
    80 // This is all that is required to test server Mtm's
       
    81 EXPORT_C CServer2* CreateMessageServerL(CMsvServerEntry*& aServerEntry)
       
    82 	{
       
    83 	// Create the server - in debug mode (doesn't load mailinit or observers
       
    84 	// and load the index synchronously)
       
    85 	CMsvServer* server = CMsvServer::NewL(ETrue);
       
    86 	CleanupStack::PushL(server);
       
    87 
       
    88 	// Return the server entry
       
    89 	aServerEntry = CMsvServerEntry::NewL(*server, KMsvNullIndexEntryId);
       
    90 	CleanupStack::Pop(); // server
       
    91 	return server;
       
    92 	}
       
    93 
       
    94 //**********************************
       
    95 //Global functions
       
    96 //**********************************
       
    97 
       
    98 
       
    99 GLDEF_C void PanicServer(TMsvServerPanic aPanic)
       
   100 //
       
   101 // Panic indicating a server fault
       
   102 //
       
   103 	{
       
   104 	User::Panic(KMsvServerPanicString, aPanic);
       
   105 	}
       
   106 
       
   107 
       
   108 
       
   109 
       
   110 
       
   111