xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheServer.h
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:23:14 +0100
branchRCL_3
changeset 18 fbd2e7cec7ef
parent 0 c8caa15ef882
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201027 Kit: 201035

/*
* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:   CXcapCacheServer
*
*/




#ifndef __XCAPCACHESERVER_H__
#define __XCAPCACHESERVER_H__

// INCLUDES
#include <e32std.h>
#include <s32file.h>
#include "ServerDefines.h"
#include "CommonDefines.h"
#include "XcapShutdownTimer.h"

//CONSTANTS
_LIT( KCacheServerRoot,                             "C:\\private\\10207421\\" );
_LIT( KCacheServerIndex,                            "C:\\private\\10207421\\index.ch" );
_LIT( KCacheServerPageFile,                         "C:\\private\\10207421\\pagefile.ch" );
_LIT( KCacheServerIndexF,                        	"index.ch" );
_LIT( KCacheServerPageFileF,                     	"pagefile.ch" );

_LIT( KCacheServerLogDir,                           "XDM" );
_LIT( KCacheServerLogFile,                          "CacheServer.txt" );
const TUint KAppDefaultHeapSize                     = 0x10000;

//FORWARD DECLARATIONs
class CXcapCacheIndex;
class CXcapCacheIndexAdmin;

// CLASS DECLARATION
class CXcapCacheServer : public CServer2                         
    {
    public:             // Constructors and destructor
        
        /**
        * Returns KErrNone
        * @return TInt System wide error code
        */
        IMPORT_C static TInt StartThreadL();
        
        /**
        * A global logging function for 8 bit data.
        * @param aCommand command to be handled
        */
        IMPORT_C static void WriteToLog( TRefByValue<const TDesC8> aFmt,... ); 

        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        static CServer2* NewLC( void );

        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        virtual CSession2* NewSessionL( const TVersion& aVersion,
        								const RMessage2& /*aMessage*/ ) const;

        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        RFs* Session();
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        TInt CacheSize( TInt& aEntryCount );
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        TInt MaxCacheSize() const;

        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        ~CXcapCacheServer();

    public:  //static

        /**
        * A global logging function for 8 bit data.
        * @param aCommand command to be handled
        */
        static RFs& FileSession();
        
        /**
        * A global logging function for 8 bit data.
        * @param aCommand command to be handled
        */
        static CXcapCacheIndex* Index();

        /**
        * A global logging function for 8 bit data.
        * @param aCommand command to be handled
        */
        static CXcapCacheIndexAdmin* IndexAdmin();
        
        /**
        * A global logging function for 8 bit data.
        * @param aCommand command to be handled
        */
        static TInt ConvertDesc( const TDesC8& aNumberDesc );
        
        /**
        * A function to handle descriptor data.
        * @return Date in heap descriptor
        */
        static HBufC* DateL();
                
        /**
        * A function to handle descriptor data.
        * @return Time in heap descriptor
        */
        static HBufC* TimeL();

        /**
        * A function to handle descriptor data.
        * @return Random string heap descriptor
        */
        static HBufC* RandomStringL();
                
        /**
        * A function to handle descriptor data.
        * @return Date and time heap descriptor
        */
        static HBufC* DateTimeL();
                
        /**
        * A function to handle descriptor data.
        * @return Date and time heap descriptor
        */
        static HBufC* DateTimeL( const TTime& aTime );
                
        /**
        * A function to handle descriptor data.
        * @param aCommand command to be handled
        */
        static TPtr8 DescriptorCast( const TDesC8& aConstData );

    private:
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        CXcapCacheServer( TInt aPriority );
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        void ConstructL();
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        void ReadMaxCacheSizeL();
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        void AddSession();
        
        /**
        * Returns the MIME type of the messages
        * @return TPtrC8 The MIME type of the messages
        */
        void DropSession();

    private:            // Data
        
        RFs                                     iFileSession;
        TInt                                    iMaxCacheSize;
        TUint                                   iSessionCount;
        CDir*                                   iCacheDirectory;
        CXcapShutdownTimer                      iShutdownTimer;
        friend class                            CXcapCacheSession;
    };

#endif

// End of File