testexecfw/stf/stfext/testmodules/teftestmod/testexecmdw/filelogger/src/server.h
changeset 2 8bb370ba6d1d
equal deleted inserted replaced
1:bbd31066657e 2:8bb370ba6d1d
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file Server.h
       
    22 */
       
    23 
       
    24 #if (!defined __ET_RFILELOGGER_SERVER_H__)
       
    25 #define __ET_RFILELOGGER_SERVER_H__
       
    26 #include <e32base.h>
       
    27 #include <f32file.h>
       
    28 #include <rfilelogger.h>
       
    29 
       
    30 
       
    31 class CActiveBase : public CActive
       
    32 	{
       
    33 public:
       
    34 	inline 	TRequestStatus& Status();
       
    35 	inline 	void SetActive();
       
    36 	inline	void Kick();
       
    37 	inline	void Prime();
       
    38 	inline	void Complete(TInt aCode);
       
    39 	inline	virtual ~CActiveBase();
       
    40 protected:
       
    41 	inline	CActiveBase();
       
    42 	};
       
    43 
       
    44 class CLogBuffer : public CBase
       
    45 	{
       
    46 public:
       
    47 	CLogBuffer(HBufC8& aBuffer);
       
    48 	~CLogBuffer();
       
    49 	inline const TDesC8& Buf();
       
    50 	inline static TInt LinkOffset();
       
    51 private:
       
    52 	TSglQueLink iLink;
       
    53 	HBufC8& iLogBuffer;
       
    54 	};
       
    55 
       
    56 class CLogServer;
       
    57 class CLogFileControl : public CActiveBase
       
    58 	{
       
    59 public:
       
    60 	enum TLogFormat{ETxt=10,EXml};
       
    61 	
       
    62 	static CLogFileControl* NewL(CLogServer& aParent, const TDesC& aLogFilePath,RFileFlogger::TLogMode aMode);
       
    63 	~CLogFileControl();
       
    64 	void RunL();
       
    65 	inline void AddLogBuffer(CLogBuffer& aBuffer);
       
    66 	inline const TDesC& LogFile();
       
    67 	inline void DoCancel();
       
    68 	inline void AddSession();
       
    69 	inline void RemoveSession();
       
    70 	inline TInt SessionCount() const;
       
    71 	inline TBool QueueEmpty() const;
       
    72 	void SetLogType(TLogFormat aLogFormat)
       
    73 	{
       
    74 		iLogFormat=aLogFormat;
       
    75 	};
       
    76 
       
    77 private:
       
    78 	void ConstructL(RFileFlogger::TLogMode aMode);
       
    79 	CLogFileControl(CLogServer& aParent, const TDesC& aLogFilePath);
       
    80 	void WriteTxt(const TDesC8 &aDes);
       
    81 	void WriteXml(const TDesC8 &aDes);
       
    82 	
       
    83 	struct TLogField8
       
    84 	{
       
    85 	TBuf8<KMaxSizOfTag> iLogTag8;
       
    86 	TBuf8<KMaxSizOfString*2> iLogValue8;	
       
    87 	};
       
    88 
       
    89 private:
       
    90 	CLogServer& iParent;
       
    91 	TBuf<KMaxLoggerFilePath> iLogFileName;
       
    92 	RFile iLogFile;
       
    93 	TSglQue<CLogBuffer> iQueue;
       
    94 	TInt iSessionCount;
       
    95 	TBool iTransmitted;
       
    96 	TLogFormat iLogFormat;
       
    97 	};
       
    98 
       
    99 class CLogServer : public CServer2
       
   100 	{
       
   101 public:
       
   102 	static CLogServer* NewL();
       
   103 	~CLogServer();
       
   104 	void ControlComplete(CLogFileControl& aControl);
       
   105 	
       
   106 	inline RPointerArray<CLogFileControl>& LogControl();
       
   107 	inline RFs& Fs();
       
   108 
       
   109 	CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
       
   110 	void SessionClosed();
       
   111 private:
       
   112 	CLogServer();
       
   113 	void ConstructL();
       
   114 private:
       
   115 	RFs iFs;
       
   116 	RPointerArray<CLogFileControl> iControl;
       
   117 	};
       
   118 
       
   119 class CLogSession : public CSession2
       
   120 	{
       
   121 public:
       
   122 	inline const CLogServer& LogServer() const;
       
   123 	CLogSession();
       
   124 	~CLogSession();
       
   125 	void ServiceL(const RMessage2& aMessage);
       
   126 private:
       
   127 	CLogFileControl* iControl;
       
   128 	};
       
   129 
       
   130 #include "Server.inl"
       
   131 
       
   132 #endif