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