os/persistentdata/traceservices/commsdebugutility/SSVR/comsdbgstub.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 and stubs all functionality.
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 "comsdbgstub.h"
sl@0
    24
sl@0
    25
sl@0
    26
sl@0
    27
/********************************************************************************/
sl@0
    28
//                      Stub Functionality from Flogsvr.cpp
sl@0
    29
sl@0
    30
sl@0
    31
sl@0
    32
CFileLoggerServer* CFileLoggerServer::NewL()
sl@0
    33
	{
sl@0
    34
sl@0
    35
	CFileLoggerServer* r=new(ELeave) CFileLoggerServer();
sl@0
    36
	CleanupStack::PushL(r);
sl@0
    37
	r->ConstructL();
sl@0
    38
	r->StartL(KFLoggerServerName);
sl@0
    39
	CleanupStack::Pop();
sl@0
    40
	return r;
sl@0
    41
	}
sl@0
    42
sl@0
    43
CFileLoggerServer::CFileLoggerServer()
sl@0
    44
	: CServer2(EPriorityNormal,ESharableSessions)
sl@0
    45
	{}
sl@0
    46
sl@0
    47
void CFileLoggerServer::ConstructL()
sl@0
    48
/**
sl@0
    49
 *
sl@0
    50
  @note Constructs the secondary thread, passing through a pointer to the log queue.
sl@0
    51
  Constructs the file parser object and parses the file, attempting to copy the
sl@0
    52
  file from the ROM if it is not found on C drive.
sl@0
    53
  Constructs the time beat.
sl@0
    54
  Performs the first UpdateMedia to ensure a media is set.
sl@0
    55
  Stubbed version does very little.
sl@0
    56
 */
sl@0
    57
	{
sl@0
    58
	}
sl@0
    59
sl@0
    60
sl@0
    61
CFileLoggerServer::~CFileLoggerServer()
sl@0
    62
	{
sl@0
    63
	}
sl@0
    64
sl@0
    65
sl@0
    66
CSession2* CFileLoggerServer::NewSessionL(const TVersion &aVersion ,const RMessage2& /*aMessage*/) const
sl@0
    67
/**
sl@0
    68
 * Create a new server session. Check that client is using current or older interface and make a new session.
sl@0
    69
 * @note Called by kernel after RFileLogger::DoConnect().
sl@0
    70
 */
sl@0
    71
	{
sl@0
    72
	if (aVersion.iMajor == 1) {}
sl@0
    73
	return CFileLogSession::NewL();
sl@0
    74
	}
sl@0
    75
sl@0
    76
sl@0
    77
sl@0
    78
TInt CFileLoggerServer::RunError(TInt aError)
sl@0
    79
/**
sl@0
    80
 * Leave has occured in CFileLogSession::ServiceL.
sl@0
    81
 * Usually this is because the appending of the message to the queue has failed
sl@0
    82
 * due to the queue being filled.
sl@0
    83
 */
sl@0
    84
	{
sl@0
    85
	return CServer2::RunError(aError);
sl@0
    86
	}
sl@0
    87
sl@0
    88
//
sl@0
    89
// CFileLogSession class definition
sl@0
    90
//
sl@0
    91
sl@0
    92
CFileLogSession* CFileLogSession::NewL()
sl@0
    93
/**
sl@0
    94
 * Construct new server end of session.
sl@0
    95
 * @note Only called from CFileLoggerServer::NewSessionL()
sl@0
    96
 */
sl@0
    97
	{
sl@0
    98
sl@0
    99
	CFileLogSession* self = new(ELeave) CFileLogSession();
sl@0
   100
	return self;
sl@0
   101
	}
sl@0
   102
sl@0
   103
CFileLogSession::CFileLogSession()
sl@0
   104
	{}
sl@0
   105
sl@0
   106
sl@0
   107
CFileLogSession::~CFileLogSession()
sl@0
   108
	{
sl@0
   109
	}
sl@0
   110
sl@0
   111
void CFileLogSession::ServiceL(const RMessage2& aMessage)
sl@0
   112
/**
sl@0
   113
 Processes message from client-side (RFileLogger)
sl@0
   114
 @note Most messages result in logs being added to the queue. If
sl@0
   115
 synchronous logging is on, this function will wait until the queue is then emptied.
sl@0
   116
 Slimline Stub version
sl@0
   117
 */
sl@0
   118
	{
sl@0
   119
	aMessage.Complete(KErrNone);
sl@0
   120
	}
sl@0
   121
sl@0
   122
sl@0
   123
sl@0
   124
/////////////////////////////////////////////////////////////////
sl@0
   125
sl@0
   126
sl@0
   127
/********************************************************************************/
sl@0
   128
//                      Stub Functionality from Flogthrd.cpp
sl@0
   129
sl@0
   130
sl@0
   131
sl@0
   132
const TInt KFLoggerServerUid=0x10004ee0;
sl@0
   133
sl@0
   134
_LIT(KFLoggerServerExecutable,"COMSDBGSVR");           ///< Filename of flogger server executable
sl@0
   135
sl@0
   136
sl@0
   137
// only needed for EKA1:
sl@0
   138
// END EKA1
sl@0
   139
sl@0
   140
sl@0
   141
sl@0
   142
EXPORT_C TInt FLogger::Start()
sl@0
   143
/**
sl@0
   144
 * Start the FLOGGER server - called by a hopeful client when they first connect.
sl@0
   145
 * @return TInt of (KErrorNone) if the server startup was successful, otherwise
sl@0
   146
 *         an error code.
sl@0
   147
 */
sl@0
   148
	{
sl@0
   149
sl@0
   150
	TRequestStatus stat;
sl@0
   151
sl@0
   152
sl@0
   153
	TInt ret;
sl@0
   154
// Different approaches for EKA1/EKA2:
sl@0
   155
	//
sl@0
   156
	// Target and EKA2 is easy, we just create a new server process. Simultaneous
sl@0
   157
	// launching of two such processes should be detected when the second one
sl@0
   158
	// attempts to create the server object, failing with KErrAlreadyExists.
sl@0
   159
	//
sl@0
   160
	RProcess server;
sl@0
   161
	ret = server.Create(KFLoggerServerExecutable,KNullDesC,TUidType(KNullUid,KNullUid,TUid::Uid(KFLoggerServerUid)));
sl@0
   162
// END EKA1/EKA2
sl@0
   163
	
sl@0
   164
	if (ret!=KErrNone)
sl@0
   165
		{
sl@0
   166
		return ret;
sl@0
   167
		}
sl@0
   168
sl@0
   169
	server.SetPriority(EPriorityHigh);
sl@0
   170
sl@0
   171
	server.Rendezvous(stat);
sl@0
   172
sl@0
   173
	server.Resume();
sl@0
   174
	
sl@0
   175
	// setting the server process priority is really just a formality since
sl@0
   176
	// we set the server's thread priorities to absolute values later anyway.
sl@0
   177
sl@0
   178
	server.Close();
sl@0
   179
sl@0
   180
	User::WaitForRequest(stat);
sl@0
   181
sl@0
   182
	return stat.Int();
sl@0
   183
	}
sl@0
   184
sl@0
   185
EXPORT_C TInt FLogger::Run()
sl@0
   186
/**
sl@0
   187
 * Start the active scheduler and create the server. This is called from the DLL entry code.
sl@0
   188
 * @return TInt of (KErrorNone) if the server startup was successful, otherwise
sl@0
   189
 *         an error code.
sl@0
   190
@internalComponent
sl@0
   191
 */
sl@0
   192
	{
sl@0
   193
sl@0
   194
	__UHEAP_MARK;
sl@0
   195
	
sl@0
   196
	RThread self;
sl@0
   197
	self.SetPriority(EPriorityAbsoluteHigh); // was EPriorityMore
sl@0
   198
	self.Close();
sl@0
   199
	
sl@0
   200
	TInt ret = KErrNone;
sl@0
   201
sl@0
   202
	CTrapCleanup* cleanup=CTrapCleanup::New();
sl@0
   203
	if (cleanup==NULL)
sl@0
   204
		ret=KErrNoMemory;
sl@0
   205
sl@0
   206
	CActiveScheduler* scheduler = NULL;
sl@0
   207
	CFileLoggerServer* server = NULL;
sl@0
   208
	if (ret==KErrNone)
sl@0
   209
		{
sl@0
   210
		scheduler = new CActiveScheduler;
sl@0
   211
		if (scheduler == NULL)
sl@0
   212
			ret = KErrNoMemory;
sl@0
   213
		else
sl@0
   214
			{
sl@0
   215
			CActiveScheduler::Install(scheduler);
sl@0
   216
			TRAP(ret, server = CFileLoggerServer::NewL());
sl@0
   217
			}
sl@0
   218
		}
sl@0
   219
sl@0
   220
	RProcess::Rendezvous(ret);
sl@0
   221
sl@0
   222
	if (ret==KErrNone)
sl@0
   223
		CActiveScheduler::Start();
sl@0
   224
sl@0
   225
	delete server;
sl@0
   226
	delete scheduler;
sl@0
   227
	delete cleanup;
sl@0
   228
sl@0
   229
	__UHEAP_MARKEND;
sl@0
   230
sl@0
   231
	return ret;
sl@0
   232
	}
sl@0
   233
sl@0
   234
sl@0
   235
sl@0
   236