1.1 --- a/epoc32/include/logwrap.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/logwrap.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,372 @@
1.4 -logwrap.h
1.5 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +#ifndef __LOGWRAP_H__
1.21 +#define __LOGWRAP_H__
1.22 +
1.23 +#include <e32base.h>
1.24 +#include <f32file.h>
1.25 +#include <barsc2.h> // For CResourceFile
1.26 +#include <logcntdef.h>
1.27 +#include <d32dbms.h>
1.28 +
1.29 +#ifndef __WINC__
1.30 +#include <logwrap.rsg>
1.31 +#endif
1.32 +
1.33 +/**
1.34 +String lengths
1.35 +@internalAll
1.36 +*/
1.37 +const TInt KLogMaxRemotePartyLength = 64;
1.38 +const TInt KLogMaxDirectionLength = 64;
1.39 +const TInt KLogMaxStatusLength = 64;
1.40 +const TInt KLogMaxSubjectLength = 64;
1.41 +const TInt KLogMaxDescriptionLength = 64;
1.42 +const TInt KLogMaxSharedStringLength = 64;
1.43 +const TInt KLogMaxNumberLength = 100;
1.44 +
1.45 +/**
1.46 +Big enough to contain any of the above strings
1.47 +Defines a modifiable buffer descriptor into which a standard string from the
1.48 +resource in the logwrap.dll resource file can be safely put.
1.49 +
1.50 +@see CLogClient::GetString()
1.51 +@publishedAll
1.52 +@released
1.53 +*/
1.54 +typedef TBuf<64> TLogString;
1.55 +
1.56 +/**
1.57 +Type definitions
1.58 +The unique event ID associated with a log event.
1.59 +
1.60 +@see CLogEvent
1.61 +@see CLogViewDuplicate
1.62 +@see CLogViewRecent
1.63 +@see CLogClient
1.64 +@see CLogBase
1.65 +@publishedAll
1.66 +@released
1.67 +*/
1.68 +typedef TInt32 TLogId;
1.69 +/**
1.70 +The duration type of an event.
1.71 +
1.72 +@see CLogEvent
1.73 +@see CLogFilter
1.74 +@publishedAll
1.75 +@released
1.76 +*/
1.77 +typedef TInt8 TLogDurationType;
1.78 +typedef TInt8 TLogRecentList;
1.79 +typedef TUint16 TLogSize;
1.80 +typedef TUint8 TLogRecentSize;
1.81 +/**
1.82 +Duration of an event, expressed as the number of seconds since the time of
1.83 +the event.
1.84 +
1.85 +@see CLogEvent
1.86 +@publishedAll
1.87 +@released
1.88 +*/
1.89 +typedef TUint32 TLogDuration;
1.90 +typedef TUint32 TLogAge;
1.91 +/**
1.92 +Link value relating a log event to an entity in another application.
1.93 +
1.94 +@see CLogEvent
1.95 +@publishedAll
1.96 +@released
1.97 +*/
1.98 +typedef TUint32 TLogLink;
1.99 +typedef TInt16 TLogStringId;
1.100 +typedef TInt16 TLogTypeId;
1.101 +/**
1.102 +The duration type of an event.
1.103 +
1.104 +@see CLogEvent
1.105 +@see CLogFilter
1.106 +@publishedAll
1.107 +@released
1.108 +*/
1.109 +typedef TInt8 TLogDurationType;
1.110 +/**
1.111 +Event flags.
1.112 +
1.113 +@see CLogEvent
1.114 +@see CLogFilter
1.115 +@publishedAll
1.116 +@released
1.117 +*/
1.118 +typedef TUint8 TLogFlags;
1.119 +
1.120 +/**
1.121 +@internalAll
1.122 +*/
1.123 +typedef TUint32 TLogViewId;
1.124 +
1.125 +/**
1.126 +Limits
1.127 +@internalAll
1.128 +*/
1.129 +const TLogId KLogNullId = -1;
1.130 +const TLogDurationType KLogNullDurationType = -1;
1.131 +const TLogDuration KLogNullDuration = 0;
1.132 +const TLogLink KLogNullLink = 0;
1.133 +const TLogRecentList KLogNullRecentList = -1;
1.134 +const TLogStringId KLogNullStringId = -1;
1.135 +const TLogTypeId KLogNullTypeId = -1;
1.136 +const TLogFlags KLogNullFlags = 0;
1.137 +const TLogFlags KLogFlagsMask = 0xF;
1.138 +const TInt KLogFlagsCount = 4;
1.139 +const TInt KLogNeverUsedId = -2;
1.140 +
1.141 +/**
1.142 +@internalAll
1.143 +*/
1.144 +const TInt KLogActiveDoNotCompleteIfActive = KMaxTInt-1;
1.145 +
1.146 +//**********************************
1.147 +// CLogActive
1.148 +//**********************************
1.149 +
1.150 +class CLogActive : public CActive
1.151 +/**
1.152 +Common active object behaviour.
1.153 +
1.154 +This is an abstract class that defines common active object behaviour for
1.155 +the log engine classes.
1.156 +@publishedAll
1.157 +@released
1.158 +*/
1.159 + {
1.160 +public:
1.161 + IMPORT_C ~CLogActive();
1.162 + //
1.163 +protected:
1.164 + IMPORT_C CLogActive(TInt aPriority);
1.165 + IMPORT_C void Queue(TRequestStatus& aStatus);
1.166 + IMPORT_C void Complete(TInt aStatus);
1.167 + IMPORT_C void DoCancel();
1.168 + //
1.169 +private:
1.170 + //
1.171 + IMPORT_C void RunL();
1.172 + virtual void DoRunL()=0;
1.173 + IMPORT_C virtual void DoComplete(TInt&);
1.174 + //
1.175 +private:
1.176 + TRequestStatus* iReport;
1.177 + };
1.178 +
1.179 +//**********************************
1.180 +// CLogEvent
1.181 +//**********************************
1.182 +
1.183 +class CLogEvent : public CBase
1.184 +/**
1.185 +Encapsulates the details of an event.
1.186 +
1.187 +Where time is used, it must be specified as UTC rather than local time.
1.188 +
1.189 +@publishedAll
1.190 +@released
1.191 +*/
1.192 + {
1.193 +public:
1.194 + IMPORT_C static CLogEvent* NewL();
1.195 + IMPORT_C ~CLogEvent();
1.196 + //
1.197 +public:
1.198 + inline TLogId Id() const;
1.199 + inline void SetId(TLogId aId);
1.200 + //
1.201 + inline TUid EventType() const;
1.202 + inline void SetEventType(TUid aId);
1.203 + //
1.204 + inline const TDesC& RemoteParty() const;
1.205 + inline void SetRemoteParty(const TDesC& aRemote);
1.206 + //
1.207 + inline const TDesC& Direction() const;
1.208 + inline void SetDirection(const TDesC& aDirection);
1.209 + //
1.210 + inline const TTime& Time() const;
1.211 + inline void SetTime(const TTime& aTime);
1.212 + //
1.213 + inline TLogDurationType DurationType() const;
1.214 + inline void SetDurationType(TLogDurationType aDurationType);
1.215 + //
1.216 + inline TLogDuration Duration() const;
1.217 + inline void SetDuration(TLogDuration aDuration);
1.218 + //
1.219 + inline const TDesC& Status() const;
1.220 + inline void SetStatus(const TDesC& aStatus);
1.221 + //
1.222 + inline const TDesC& Subject() const;
1.223 + inline void SetSubject(const TDesC& aSubject);
1.224 + //
1.225 + inline const TDesC& Number() const;
1.226 + inline void SetNumber(const TDesC& aNumber);
1.227 + //
1.228 + inline TLogContactItemId Contact() const;
1.229 + inline void SetContact(TLogContactItemId aContact);
1.230 + //
1.231 + inline TLogLink Link() const;
1.232 + inline void SetLink(TLogLink aLink);
1.233 + //
1.234 + inline const TDesC& Description() const;
1.235 + inline void SetDescription(const TDesC& aDescription);
1.236 + //
1.237 + inline TLogFlags Flags() const;
1.238 + inline void SetFlags(TLogFlags aFlags);
1.239 + inline void ClearFlags(TLogFlags aFlags);
1.240 + //
1.241 + inline const TDesC8& Data() const;
1.242 + IMPORT_C void SetDataL(RReadStream& aStream, TInt aLen);
1.243 + IMPORT_C void SetDataL(const TDesC8& aData);
1.244 + //
1.245 + IMPORT_C void CopyL(const CLogEvent& aEvent);
1.246 +
1.247 + IMPORT_C void InternalizeL(RReadStream& aStream);
1.248 + IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
1.249 +
1.250 + //
1.251 +private:
1.252 + CLogEvent();
1.253 + void ConstructL();
1.254 + void InternalizeBufL(RReadStream& aStream, HBufC*& aDes);
1.255 + //
1.256 +private:
1.257 + TLogId iId;
1.258 + TUid iEventType;
1.259 + TTime iTime;
1.260 + TLogDurationType iDurationType;
1.261 + TLogDuration iDuration;
1.262 + TLogContactItemId iContact;
1.263 + TLogLink iLink;
1.264 + TLogFlags iFlags;
1.265 + HBufC* iDescription;
1.266 + HBufC* iRemoteParty;
1.267 + HBufC* iDirection;
1.268 + HBufC* iStatus;
1.269 + HBufC* iSubject;
1.270 + HBufC* iNumber;
1.271 + HBufC8* iData;
1.272 + };
1.273 +
1.274 +//**********************************
1.275 +// CLogBase
1.276 +//**********************************
1.277 +
1.278 +class CLogBase : public CLogActive
1.279 +/**
1.280 +Base class for the log engine implementation.
1.281 +
1.282 +This class defines the interface that client code uses to perform simple actions
1.283 +on the log database.
1.284 +
1.285 +The class provides default implementations for the event handling functions.
1.286 +The Log Engine, i.e. an instance of CLogClient, is derived from this class
1.287 +and provides implementations for the event handling functions.
1.288 +
1.289 +The class also deals with some aspects of resource file handling.
1.290 +
1.291 +An instance of this class is constructed by the log wrapper, CLogWrapper,
1.292 +if the phone does not implement logging.
1.293 +
1.294 +An instance of this class is never constructed by clients.
1.295 +
1.296 +@see CLogClient
1.297 +@see CLogWrapper
1.298 +@publishedAll
1.299 +@released
1.300 +*/
1.301 + {
1.302 +public:
1.303 + IMPORT_C CLogBase(TInt aPriority);
1.304 + IMPORT_C ~CLogBase();
1.305 + //
1.306 + IMPORT_C virtual void GetEvent(CLogEvent& aEvent, TRequestStatus& aStatus);
1.307 + IMPORT_C virtual void AddEvent(CLogEvent& aEvent, TRequestStatus& aStatus);
1.308 + IMPORT_C virtual void ChangeEvent(const CLogEvent& aEvent, TRequestStatus& aStatus);
1.309 + IMPORT_C virtual void DeleteEvent(TLogId aId, TRequestStatus& aStatus);
1.310 + //
1.311 + IMPORT_C virtual TInt GetString(TDes& aString, TInt aId) const;
1.312 + //
1.313 +protected:
1.314 + IMPORT_C void LoadResourcesL(RFs& aFs);
1.315 + inline const CResourceFile* ResourceFile() const;
1.316 + //
1.317 +private:
1.318 + void DoRunL();
1.319 + //
1.320 +private:
1.321 + CResourceFile* iResourceFile;
1.322 +
1.323 + //
1.324 +private:
1.325 + IMPORT_C virtual void CLogBase_Reserved1();
1.326 + TAny* CLogBase_Reserved;
1.327 + };
1.328 +
1.329 +//**********************************
1.330 +// CLogWrapper
1.331 +//**********************************
1.332 +
1.333 +class CLogWrapper : public CBase
1.334 +/**
1.335 +The log wrapper.
1.336 +
1.337 +As some UI variants do not use a Log Engine, the log wrapper provides a consistent
1.338 +interface to clients that need to work, without being changed, with multiple
1.339 +UI variants.
1.340 +
1.341 +The log wrapper is provided in its own DLL, the logwrap.dll.
1.342 +
1.343 +If a Log Engine is not installed on a phone, the log wrapper creates an instance
1.344 +of the CLogBase class, whose event handling requests complete with KErrNotSupported
1.345 +and whose functions return KErrNotSupported.
1.346 +
1.347 +If a Log Engine is installed on a phone, the log wrapper creates an instance
1.348 +of the CLogClient class, provided in a separate DLL, the logcli.dll . The
1.349 +CLogClient class derives from CLogBase and provides implementations for the
1.350 +event handling requests and functions.
1.351 +
1.352 +@see CLogBase
1.353 +@see CLogClient
1.354 +@publishedAll
1.355 +@released
1.356 +*/
1.357 + {
1.358 +public:
1.359 + IMPORT_C static CLogWrapper* NewL(RFs& aFs, TInt aPriority = CActive::EPriorityStandard);
1.360 + IMPORT_C ~CLogWrapper();
1.361 + //
1.362 + inline CLogBase& Log();
1.363 + IMPORT_C TBool ClientAvailable() const;
1.364 + //
1.365 +private:
1.366 + CLogWrapper();
1.367 + void ConstructL(RFs& aFs, TInt aPriority);
1.368 + //
1.369 +private:
1.370 + CLogBase* iBase;
1.371 + };
1.372 +
1.373 +#include <logwrap.inl>
1.374 +#include <logeng.h>
1.375 +
1.376 +#endif