wvuing/wvlogger/Src/CCALoggerWriter.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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:  History file writer class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CCALOGGERWRITER_H__
       
    20 #define __CCALOGGERWRITER_H__
       
    21 
       
    22 //  INCLUDES
       
    23 
       
    24 #include <f32file.h>
       
    25 #include <s32file.h>
       
    26 
       
    27 #include "MCALoggerWriteInterface.h"
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 
       
    31 class MCALoggerWriteObserver;
       
    32 
       
    33 // CLASS DECLARATION
       
    34 
       
    35 /**
       
    36  *  History file writer class
       
    37  *
       
    38  *  @lib CALogger.dll
       
    39  *  @since 2.1
       
    40  */
       
    41 class CCALoggerWriter : public CBase, public MCALoggerWriteInterface
       
    42     {
       
    43     public:
       
    44 
       
    45         /**
       
    46          * Destructor.
       
    47          * If logging is still on. Ends it.
       
    48          */
       
    49         virtual ~CCALoggerWriter();
       
    50 
       
    51         /**
       
    52          *	Two-phased constructor.
       
    53          *	Leaves if creation of CCALoggerWriter fails.
       
    54          *	Leaves if constructL fails.
       
    55          *	@param aObserver Write observer that will be informed about write
       
    56          *					situations like file add and remove.
       
    57          *	@param aFileSession Open file session for file server utilities.
       
    58          *	@return Instance to CCALoggerWriter
       
    59          */
       
    60         static CCALoggerWriter* NewL(	MCALoggerWriteObserver& aObserver,
       
    61                                       RFs& aFileSession );
       
    62 
       
    63     protected:
       
    64 
       
    65         /**
       
    66          * C++ default constructor.
       
    67          */
       
    68         CCALoggerWriter( MCALoggerWriteObserver& aObserver, RFs& aFileSession );
       
    69 
       
    70     public: // Inherited from MCALoggerWriteInterface.
       
    71         /**
       
    72          * Starts logging. Sets logging on. Informs observer to addfile.
       
    73          *	Leaves with KErrArgument if header is NULL.
       
    74          *	Leaves with KErrInUse if loggins is already on.
       
    75          *	Leaves if MCALoggerWriteObserver::CreateNewFilenameL fails.
       
    76          *	Leaves if MCALoggerMessageHeader::SetFilenameL fails.
       
    77          *	Leaves if MCALoggerWriteObserver::AddFileL fails.
       
    78          *	Leaves if file creation fails.
       
    79          * @since 2.1
       
    80          * @param aFile Header information.
       
    81          */
       
    82         void StartLoggingL( MCALoggerMessageHeader* aFile );
       
    83 
       
    84         /**
       
    85          *	Ends logging. Close the file. Informs observer to remove file.
       
    86          *	Sets logging off.
       
    87          *	Leaves if MCALoggerWriteObserver::RemoveFileL fails.
       
    88          *	@since 2.1
       
    89          */
       
    90         void EndLoggingL();
       
    91 
       
    92         /**
       
    93          *	Checks if logging is on.
       
    94          *	@since 2.1
       
    95          *	@return ETrue if logging is on. EFalse if logging is off.
       
    96          */
       
    97         TBool IsLoggingOn();
       
    98 
       
    99         /**
       
   100          *	Logs message. Logs message if there is enough memory.
       
   101          *	Leaves if memory check fails with KErrDiskFull
       
   102          *	Leaves if logging is not on with KErrNotReady
       
   103          *	Leaves if logging fails.
       
   104          *	@since 2.1
       
   105          *	@param aMessage Message information.
       
   106          */
       
   107         void MakeLogL( MCALoggerMessage& aMessage );
       
   108 
       
   109 
       
   110     public:
       
   111 
       
   112         //fix - refer Ui Spec Approved Version 1.0
       
   113         //(Instant Messaging NG 001 151006.pdf)
       
   114         //Section 10.2.10 Pg 131 -
       
   115         //"In case user has saved the image already or sent it
       
   116         //by himself, this option(save) is not available."
       
   117 
       
   118         /**
       
   119          * Note : Please dont delete while merging the wvui20 changes
       
   120          * Relogs the file and saves all the messages
       
   121          * only if the file has become dirty.
       
   122          * New implementation - Used if user saves an image
       
   123          * in saved conversations that info is stored back on
       
   124          * to the file and subsequently we dont allow resaving of the
       
   125          * same image  */
       
   126 
       
   127         /**
       
   128          * Starts relogging. Sets logging on.
       
   129          *	Leaves with KErrArgument if header is NULL.
       
   130          *	Leaves with KErrInUse if loggins is already on.
       
   131          *	Leaves if file replacing of file fails.
       
   132          * @since 3.2
       
   133          * @param aFile Header information.
       
   134          */
       
   135         void ReLoggingL( MCALoggerMessageHeader& aFile );
       
   136 
       
   137         /**
       
   138          *	Ends Relogging. Close the file.
       
   139          *	Sets logging off.
       
   140          *	@since 3.2
       
   141          */
       
   142         void EndReLogging();
       
   143 
       
   144     private: //Data
       
   145 
       
   146         /**
       
   147          * Observer for writer.
       
   148          */
       
   149         MCALoggerWriteObserver& iManager;
       
   150 
       
   151         /**
       
   152          *	Flag which tells status of log. ETrue, logging is on. EFalse off.
       
   153          */
       
   154         TBool iLoggingOn;
       
   155 
       
   156         // handle to the file server
       
   157         RFs& iFileSession;
       
   158 
       
   159         // File stream handle
       
   160         RFileWriteStream iFileStream;
       
   161     };
       
   162 
       
   163 #endif      // __CCALOGGERWRITER_H__
       
   164 
       
   165 // End of File