os/persistentdata/traceservices/commsdebugutility/SSVR/comsdbgthrd.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Implements the FLogger server process startup
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @internalComponent
sl@0
    21
*/
sl@0
    22
sl@0
    23
#include <comms-infras/commsdebugutility.h>
sl@0
    24
#include "comsdbgstd.h"
sl@0
    25
sl@0
    26
const TInt KFLoggerServerUid=0x10004ee0;
sl@0
    27
sl@0
    28
_LIT(KFLoggerServerExecutable,"COMSDBGSVR");           ///< Filename of flogger server executable
sl@0
    29
sl@0
    30
sl@0
    31
// only needed for EKA1:
sl@0
    32
// END EKA1
sl@0
    33
sl@0
    34
sl@0
    35
sl@0
    36
EXPORT_C TInt FLogger::Start()
sl@0
    37
/**
sl@0
    38
 * Start the FLOGGER server - called by a hopeful client when they first connect.
sl@0
    39
 * @return TInt of (KErrorNone) if the server startup was successful, otherwise
sl@0
    40
 *         an error code.
sl@0
    41
 */
sl@0
    42
	{
sl@0
    43
sl@0
    44
	TRequestStatus stat;
sl@0
    45
sl@0
    46
sl@0
    47
	TInt ret;
sl@0
    48
// Different approaches for EKA1/EKA2:
sl@0
    49
	//
sl@0
    50
	// Target and EKA2 is easy, we just create a new server process. Simultaneous
sl@0
    51
	// launching of two such processes should be detected when the second one
sl@0
    52
	// attempts to create the server object, failing with KErrAlreadyExists.
sl@0
    53
	//
sl@0
    54
	RProcess server;
sl@0
    55
	ret = server.Create(KFLoggerServerExecutable,KNullDesC,TUidType(KNullUid,KNullUid,TUid::Uid(KFLoggerServerUid)));
sl@0
    56
// END EKA1/EKA2
sl@0
    57
	
sl@0
    58
	if (ret!=KErrNone)
sl@0
    59
		{
sl@0
    60
		return ret;
sl@0
    61
		}
sl@0
    62
sl@0
    63
	server.SetPriority(EPriorityHigh);
sl@0
    64
sl@0
    65
	server.Rendezvous(stat);
sl@0
    66
sl@0
    67
	server.Resume();
sl@0
    68
	
sl@0
    69
	// setting the server process priority is really just a formality since
sl@0
    70
	// we set the server's thread priorities to absolute values later anyway.
sl@0
    71
	server.Close();
sl@0
    72
sl@0
    73
	User::WaitForRequest(stat);
sl@0
    74
sl@0
    75
	return stat.Int();
sl@0
    76
	}
sl@0
    77
sl@0
    78
EXPORT_C TInt FLogger::Run()
sl@0
    79
/**
sl@0
    80
 * Start the active scheduler and create the server. This is called from the DLL entry code.
sl@0
    81
 * @return TInt of (KErrorNone) if the server startup was successful, otherwise
sl@0
    82
 *         an error code.
sl@0
    83
@internalComponent
sl@0
    84
 */
sl@0
    85
	{
sl@0
    86
sl@0
    87
	__UHEAP_MARK;
sl@0
    88
	
sl@0
    89
	RThread self;
sl@0
    90
	self.SetPriority(EPriorityAbsoluteHigh); // was EPriorityMore
sl@0
    91
	self.Close();
sl@0
    92
	
sl@0
    93
	TInt ret = KErrNone;
sl@0
    94
sl@0
    95
	CTrapCleanup* cleanup=CTrapCleanup::New();
sl@0
    96
	if (cleanup==NULL)
sl@0
    97
		ret=KErrNoMemory;
sl@0
    98
sl@0
    99
	CActiveScheduler* scheduler = NULL;
sl@0
   100
	CFileLoggerServer* server = NULL;
sl@0
   101
	if (ret==KErrNone)
sl@0
   102
		{
sl@0
   103
		scheduler = new CActiveScheduler;
sl@0
   104
		if (scheduler == NULL)
sl@0
   105
			ret = KErrNoMemory;
sl@0
   106
		else
sl@0
   107
			{
sl@0
   108
			CActiveScheduler::Install(scheduler);
sl@0
   109
			TRAP(ret, server = CFileLoggerServer::NewL());
sl@0
   110
			}
sl@0
   111
		}
sl@0
   112
sl@0
   113
	RProcess::Rendezvous(ret);
sl@0
   114
sl@0
   115
	if (ret==KErrNone)
sl@0
   116
		CActiveScheduler::Start();
sl@0
   117
sl@0
   118
	delete server;
sl@0
   119
	delete scheduler;
sl@0
   120
	delete cleanup;
sl@0
   121
sl@0
   122
	__UHEAP_MARKEND;
sl@0
   123
sl@0
   124
	return ret;
sl@0
   125
	}
sl@0
   126
sl@0
   127
sl@0
   128