epoc32/include/logwrap.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 logwrap.h
     1 // Copyright (c) 2003-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __LOGWRAP_H__
       
    17 #define __LOGWRAP_H__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <f32file.h>
       
    21 #include <barsc2.h> // For CResourceFile
       
    22 #include <logcntdef.h>
       
    23 #include <d32dbms.h>
       
    24 
       
    25 #ifndef __WINC__
       
    26 #include <logwrap.rsg>
       
    27 #endif
       
    28 
       
    29 /**
       
    30 String lengths
       
    31 @internalAll
       
    32 */
       
    33 const TInt KLogMaxRemotePartyLength = 64;
       
    34 const TInt KLogMaxDirectionLength = 64;
       
    35 const TInt KLogMaxStatusLength = 64;
       
    36 const TInt KLogMaxSubjectLength = 64;
       
    37 const TInt KLogMaxDescriptionLength = 64;
       
    38 const TInt KLogMaxSharedStringLength = 64;
       
    39 const TInt KLogMaxNumberLength = 100;
       
    40 
       
    41 /** 
       
    42 Big enough to contain any of the above strings
       
    43 Defines a modifiable buffer descriptor into which a standard string from the 
       
    44 resource in the logwrap.dll resource file can be safely put.
       
    45 
       
    46 @see CLogClient::GetString()
       
    47 @publishedAll
       
    48 @released
       
    49 */
       
    50 typedef TBuf<64> TLogString;
       
    51 
       
    52 /** 
       
    53 Type definitions
       
    54 The unique event ID associated with a log event.
       
    55 
       
    56 @see CLogEvent
       
    57 @see CLogViewDuplicate
       
    58 @see CLogViewRecent
       
    59 @see CLogClient
       
    60 @see CLogBase 
       
    61 @publishedAll
       
    62 @released
       
    63 */
       
    64 typedef TInt32	TLogId;
       
    65 /** 
       
    66 The duration type of an event.
       
    67 
       
    68 @see CLogEvent
       
    69 @see CLogFilter
       
    70 @publishedAll
       
    71 @released
       
    72 */
       
    73 typedef TInt8	TLogDurationType;
       
    74 typedef TInt8	TLogRecentList;
       
    75 typedef TUint16 TLogSize;
       
    76 typedef TUint8	TLogRecentSize;
       
    77 /** 
       
    78 Duration of an event, expressed as the number of seconds since the time of 
       
    79 the event.
       
    80 
       
    81 @see CLogEvent
       
    82 @publishedAll
       
    83 @released
       
    84 */
       
    85 typedef TUint32	TLogDuration;
       
    86 typedef TUint32	TLogAge;
       
    87 /** 
       
    88 Link value relating a log event to an entity in another application.
       
    89 
       
    90 @see CLogEvent
       
    91 @publishedAll
       
    92 @released
       
    93 */
       
    94 typedef TUint32	TLogLink;
       
    95 typedef TInt16	TLogStringId;
       
    96 typedef TInt16	TLogTypeId;
       
    97 /** 
       
    98 The duration type of an event.
       
    99 
       
   100 @see CLogEvent
       
   101 @see CLogFilter
       
   102 @publishedAll
       
   103 @released
       
   104 */
       
   105 typedef TInt8	TLogDurationType;
       
   106 /** 
       
   107 Event flags.
       
   108 
       
   109 @see CLogEvent
       
   110 @see CLogFilter
       
   111 @publishedAll
       
   112 @released
       
   113 */
       
   114 typedef TUint8	TLogFlags;
       
   115 
       
   116 /**
       
   117 @internalAll
       
   118 */
       
   119 typedef TUint32	TLogViewId;
       
   120 
       
   121 /**
       
   122 Limits
       
   123 @internalAll
       
   124 */
       
   125 const TLogId KLogNullId = -1;
       
   126 const TLogDurationType KLogNullDurationType = -1;
       
   127 const TLogDuration KLogNullDuration = 0;
       
   128 const TLogLink KLogNullLink = 0;
       
   129 const TLogRecentList KLogNullRecentList = -1;
       
   130 const TLogStringId KLogNullStringId = -1;
       
   131 const TLogTypeId KLogNullTypeId = -1;
       
   132 const TLogFlags KLogNullFlags = 0;
       
   133 const TLogFlags KLogFlagsMask = 0xF;
       
   134 const TInt KLogFlagsCount = 4;
       
   135 const TInt KLogNeverUsedId = -2;
       
   136 
       
   137 /**
       
   138 @internalAll
       
   139 */
       
   140 const TInt KLogActiveDoNotCompleteIfActive = KMaxTInt-1;
       
   141 
       
   142 //**********************************
       
   143 // CLogActive
       
   144 //**********************************
       
   145 
       
   146 class CLogActive : public CActive
       
   147 /** 
       
   148 Common active object behaviour.
       
   149 
       
   150 This is an abstract class that defines common active object behaviour for 
       
   151 the log engine classes.
       
   152 @publishedAll
       
   153 @released
       
   154 */
       
   155 	{
       
   156 public:
       
   157 	IMPORT_C ~CLogActive();
       
   158 	//
       
   159 protected:
       
   160 	IMPORT_C CLogActive(TInt aPriority);
       
   161 	IMPORT_C void Queue(TRequestStatus& aStatus);
       
   162 	IMPORT_C void Complete(TInt aStatus);
       
   163 	IMPORT_C void DoCancel();
       
   164 	//
       
   165 private:
       
   166 	//
       
   167 	IMPORT_C void RunL();
       
   168 	virtual void DoRunL()=0;
       
   169 	IMPORT_C virtual void DoComplete(TInt&);
       
   170 	//
       
   171 private:
       
   172 	TRequestStatus* iReport;
       
   173 	};
       
   174 
       
   175 //**********************************
       
   176 // CLogEvent
       
   177 //**********************************
       
   178 
       
   179 class CLogEvent : public CBase
       
   180 /** 
       
   181 Encapsulates the details of an event.
       
   182 
       
   183 Where time is used, it must be specified as UTC rather than local time.
       
   184 
       
   185 @publishedAll
       
   186 @released
       
   187 */
       
   188 	{
       
   189 public:
       
   190 	IMPORT_C static CLogEvent* NewL();
       
   191 	IMPORT_C ~CLogEvent();
       
   192 	//
       
   193 public:
       
   194 	inline TLogId Id() const;
       
   195 	inline void SetId(TLogId aId);
       
   196 	//
       
   197 	inline TUid EventType() const;
       
   198 	inline void SetEventType(TUid aId);
       
   199 	//
       
   200 	inline const TDesC& RemoteParty() const;
       
   201 	inline void SetRemoteParty(const TDesC& aRemote);
       
   202 	//
       
   203 	inline const TDesC& Direction() const;
       
   204 	inline void SetDirection(const TDesC& aDirection);
       
   205 	//
       
   206 	inline const TTime& Time() const;
       
   207 	inline void SetTime(const TTime& aTime);
       
   208 	//
       
   209 	inline TLogDurationType DurationType() const;
       
   210 	inline void SetDurationType(TLogDurationType aDurationType);
       
   211 	//
       
   212 	inline TLogDuration Duration() const;
       
   213 	inline void SetDuration(TLogDuration aDuration);
       
   214 	//
       
   215 	inline const TDesC& Status() const;
       
   216 	inline void SetStatus(const TDesC& aStatus);
       
   217 	//
       
   218 	inline const TDesC& Subject() const;
       
   219 	inline void SetSubject(const TDesC& aSubject);
       
   220 	//
       
   221 	inline const TDesC& Number() const;
       
   222 	inline void SetNumber(const TDesC& aNumber);
       
   223 	//
       
   224 	inline TLogContactItemId Contact() const;
       
   225 	inline void SetContact(TLogContactItemId  aContact);
       
   226 	//
       
   227 	inline TLogLink Link() const;
       
   228 	inline void SetLink(TLogLink aLink);
       
   229 	//
       
   230 	inline const TDesC& Description() const;
       
   231 	inline void SetDescription(const TDesC& aDescription);
       
   232 	//
       
   233 	inline TLogFlags Flags() const;
       
   234 	inline void SetFlags(TLogFlags aFlags);
       
   235 	inline void ClearFlags(TLogFlags aFlags);
       
   236 	//
       
   237 	inline const TDesC8& Data() const;
       
   238 	IMPORT_C void SetDataL(RReadStream& aStream, TInt aLen);
       
   239 	IMPORT_C void SetDataL(const TDesC8& aData);
       
   240 	//
       
   241 	IMPORT_C void CopyL(const CLogEvent& aEvent);
       
   242 
       
   243 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   244 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
       
   245 
       
   246 	//
       
   247 private:
       
   248 	CLogEvent();
       
   249 	void ConstructL();
       
   250 	void InternalizeBufL(RReadStream& aStream, HBufC*& aDes);
       
   251 	//
       
   252 private:
       
   253 	TLogId iId;
       
   254 	TUid iEventType;
       
   255 	TTime iTime;
       
   256 	TLogDurationType iDurationType;
       
   257 	TLogDuration iDuration;
       
   258 	TLogContactItemId  iContact;
       
   259 	TLogLink iLink;
       
   260 	TLogFlags iFlags;
       
   261 	HBufC* iDescription;
       
   262 	HBufC* iRemoteParty;
       
   263 	HBufC* iDirection;
       
   264 	HBufC* iStatus;
       
   265 	HBufC* iSubject;
       
   266 	HBufC* iNumber;
       
   267 	HBufC8* iData;
       
   268 	};
       
   269 
       
   270 //**********************************
       
   271 // CLogBase
       
   272 //**********************************
       
   273 
       
   274 class CLogBase : public CLogActive
       
   275 /** 
       
   276 Base class for the log engine implementation.
       
   277 
       
   278 This class defines the interface that client code uses to perform simple actions 
       
   279 on the log database.
       
   280 
       
   281 The class provides default implementations for the event handling functions. 
       
   282 The Log Engine, i.e. an instance of CLogClient, is derived from this class 
       
   283 and provides implementations for the event handling functions.
       
   284 
       
   285 The class also deals with some aspects of resource file handling.
       
   286 
       
   287 An instance of this class is constructed by the log wrapper, CLogWrapper, 
       
   288 if the phone does not implement logging.
       
   289 
       
   290 An instance of this class is never constructed by clients.
       
   291 
       
   292 @see CLogClient
       
   293 @see CLogWrapper
       
   294 @publishedAll
       
   295 @released
       
   296 */
       
   297 	{
       
   298 public:
       
   299 	IMPORT_C CLogBase(TInt aPriority);
       
   300 	IMPORT_C ~CLogBase();
       
   301 	//
       
   302 	IMPORT_C virtual void GetEvent(CLogEvent& aEvent, TRequestStatus& aStatus);
       
   303 	IMPORT_C virtual void AddEvent(CLogEvent& aEvent, TRequestStatus& aStatus);
       
   304 	IMPORT_C virtual void ChangeEvent(const CLogEvent& aEvent, TRequestStatus& aStatus);
       
   305 	IMPORT_C virtual void DeleteEvent(TLogId aId, TRequestStatus& aStatus);
       
   306 	//
       
   307 	IMPORT_C virtual TInt GetString(TDes& aString, TInt aId) const;
       
   308 	//
       
   309 protected:
       
   310 	IMPORT_C void LoadResourcesL(RFs& aFs);
       
   311 	inline const CResourceFile* ResourceFile() const;
       
   312 	//
       
   313 private:
       
   314 	void DoRunL();
       
   315 	//
       
   316 private:
       
   317 	CResourceFile* iResourceFile;
       
   318 	
       
   319 	//
       
   320 private:
       
   321 	IMPORT_C virtual void CLogBase_Reserved1();
       
   322 	TAny* CLogBase_Reserved;
       
   323 	};
       
   324 
       
   325 //**********************************
       
   326 // CLogWrapper
       
   327 //**********************************
       
   328 
       
   329 class CLogWrapper : public CBase
       
   330 /** 
       
   331 The log wrapper.
       
   332 
       
   333 As some UI variants do not use a Log Engine, the log wrapper provides a consistent 
       
   334 interface to clients that need to work, without being changed, with multiple 
       
   335 UI variants.
       
   336 
       
   337 The log wrapper is provided in its own DLL, the logwrap.dll.
       
   338 
       
   339 If a Log Engine is not installed on a phone, the log wrapper creates an instance 
       
   340 of the CLogBase class, whose event handling requests complete with KErrNotSupported 
       
   341 and whose functions return KErrNotSupported.
       
   342 
       
   343 If a Log Engine is installed on a phone, the log wrapper creates an instance 
       
   344 of the CLogClient class, provided in a separate DLL, the logcli.dll . The 
       
   345 CLogClient class derives from CLogBase and provides implementations for the 
       
   346 event handling requests and functions.
       
   347 
       
   348 @see CLogBase
       
   349 @see CLogClient
       
   350 @publishedAll
       
   351 @released
       
   352 */
       
   353 	{
       
   354 public:
       
   355 	IMPORT_C static CLogWrapper* NewL(RFs& aFs, TInt aPriority = CActive::EPriorityStandard);
       
   356 	IMPORT_C ~CLogWrapper();
       
   357 	//
       
   358 	inline CLogBase& Log();
       
   359 	IMPORT_C TBool ClientAvailable() const;
       
   360 	//
       
   361 private:
       
   362 	CLogWrapper();
       
   363 	void ConstructL(RFs& aFs, TInt aPriority);
       
   364 	//
       
   365 private:
       
   366 	CLogBase* iBase;
       
   367 	};
       
   368 
       
   369 #include <logwrap.inl>
       
   370 #include <logeng.h>
       
   371 
       
   372 #endif