mmfenh/profilesettingsmonitor/src/ProfileSettingsMonitorServer.cpp
changeset 0 71ca22bcf22a
equal deleted inserted replaced
-1:000000000000 0:71ca22bcf22a
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This file contains implementation of ProfileSettingsMonitorServer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "MmfProfileSettingsMonitorClientServer.h"
       
    20 #include "ProfileSettingsMonitorServer.h"
       
    21 #include "ProfileSettingsMonitorServerImpl.h"
       
    22 
       
    23 CProfileSettingsMonitorServer* CProfileSettingsMonitorServer::NewL()
       
    24 	{
       
    25 	CProfileSettingsMonitorServer* s = new(ELeave) CProfileSettingsMonitorServer();
       
    26 	CleanupStack::PushL(s);
       
    27 	s->ConstructL();
       
    28 	CleanupStack::Pop();
       
    29 	return s;
       
    30 	}
       
    31 
       
    32 CProfileSettingsMonitorServer::CProfileSettingsMonitorServer()
       
    33     :   CServer2(EPriorityStandard)
       
    34 	{
       
    35 	}
       
    36 
       
    37 void CProfileSettingsMonitorServer::ConstructL()
       
    38 	{
       
    39 	// Call base class to Start server
       
    40 	iServerImpl = CProfileSettingsMonitorServerImpl::NewL();
       
    41 	StartL(KNullDesC);
       
    42 	}
       
    43 
       
    44 CProfileSettingsMonitorServer::~CProfileSettingsMonitorServer()
       
    45 	{
       
    46 	}
       
    47 
       
    48 CSession2* CProfileSettingsMonitorServer::NewSessionL(const TVersion& /*aVersion*/,const RMessage2& /*aMessage*/) const
       
    49 	{
       
    50 	    User::Leave(KErrNotSupported);
       
    51 	    return NULL;
       
    52 	}
       
    53 
       
    54 static void StartProfileSettingsMonitorServerL()
       
    55 // Perform all server initialisation, in particular creation of the
       
    56 // scheduler and server and then run the scheduler
       
    57 //
       
    58 	{
       
    59 	// Naming the server thread after the server helps to debug panics
       
    60 	User::LeaveIfError(User::RenameThread(KProfileSettingsMonitorServerName));
       
    61 
       
    62 	// Create and install the active scheduler we need
       
    63 	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
       
    64 	CleanupStack::PushL(scheduler);
       
    65 	CActiveScheduler::Install(scheduler);
       
    66 
       
    67 	//create the server & leave it on the cleanupstack
       
    68 	CleanupStack::PushL(CProfileSettingsMonitorServer::NewL());
       
    69 
       
    70 	// Initialisation complete, now signal the client
       
    71 	RProcess::Rendezvous(KErrNone);
       
    72 	
       
    73 	// Start the scheduler and wait for client requests
       
    74 	CActiveScheduler::Start();
       
    75 
       
    76     //now exiting the server so cleanup
       
    77 	CleanupStack::PopAndDestroy(2);//scheduler and server
       
    78 	}
       
    79 
       
    80 TInt E32Main()
       
    81 //
       
    82 // Server process entry-point
       
    83 // Recover the startup parameters and run the server
       
    84 //
       
    85 	{
       
    86 	__UHEAP_MARK;
       
    87 	//
       
    88 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
    89 	TInt r=KErrNoMemory;
       
    90 	if (cleanup)
       
    91 		{
       
    92 		TRAP(r,StartProfileSettingsMonitorServerL());
       
    93 		delete cleanup;
       
    94 		}
       
    95 	//
       
    96 	__UHEAP_MARKEND;
       
    97 	return r;
       
    98 	}
       
    99