os/persistentdata/loggingservices/eventlogger/LogCli/src/LOGVIEW.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <logview.h>
sl@0
    17
sl@0
    18
// User includes
sl@0
    19
#include <logwrap.h>
sl@0
    20
#include <logcli.h>
sl@0
    21
#include "logclipanic.h"
sl@0
    22
#include "logservcli.h"
sl@0
    23
#include "logpackage.h"
sl@0
    24
#include "logclientop.h"
sl@0
    25
#include "LogViewObserver.h"
sl@0
    26
#include "LogViewWindow.h"
sl@0
    27
sl@0
    28
// Constants
sl@0
    29
const TInt KLogDefaultWindowSize = 10;
sl@0
    30
sl@0
    31
//**********************************
sl@0
    32
// CLogView
sl@0
    33
//**********************************
sl@0
    34
sl@0
    35
CLogView::CLogView(CLogClient& aClient, TInt aPriority/* = CActive:EPriorityStandard*/)
sl@0
    36
: CLogActive(aPriority), iClient(aClient)
sl@0
    37
	{
sl@0
    38
	// Get the view id
sl@0
    39
	iViewId = iClient.Session().AllocateIdView();
sl@0
    40
	}
sl@0
    41
sl@0
    42
EXPORT_C CLogView::~CLogView()
sl@0
    43
/** Frees all resources owned by this object prior to its destruction. In particular, 
sl@0
    44
any outstanding asynchronous request is cancelled. */
sl@0
    45
	{
sl@0
    46
	Cancel();
sl@0
    47
sl@0
    48
	delete iEvent;
sl@0
    49
	delete iPackage;
sl@0
    50
	delete iMaintain;
sl@0
    51
	delete iLogViewObserver;
sl@0
    52
	delete iWindow;
sl@0
    53
sl@0
    54
	// Delete the view
sl@0
    55
	iClient.Session().Send(ELogViewDelete, TIpcArgs(iViewId)); // Not much we can do if this goes wrong
sl@0
    56
	}
sl@0
    57
sl@0
    58
void CLogView::ConstructL(TInt aType, MLogViewChangeObserver* aObserver)
sl@0
    59
	{
sl@0
    60
	iType = aType;
sl@0
    61
	iLogViewChangeObserver = aObserver;
sl@0
    62
	iPackage = CLogPackage::NewL();
sl@0
    63
	iEvent = CLogEvent::NewL();
sl@0
    64
	iMaintain = new(ELeave)CLogMaintainClientOp(iClient.Session(), *iPackage, Priority());
sl@0
    65
sl@0
    66
	PrepareViewChildrenL();
sl@0
    67
	}
sl@0
    68
sl@0
    69
void CLogView::NotifyLogServerTerminatedL()
sl@0
    70
	{
sl@0
    71
	PrepareViewChildrenL();
sl@0
    72
	}
sl@0
    73
sl@0
    74
void CLogView::PrepareViewChildrenL()
sl@0
    75
	{
sl@0
    76
	// Construct the view in the server
sl@0
    77
	TIpcArgs aArgs;
sl@0
    78
	aArgs.Set(0, iViewId);
sl@0
    79
	aArgs.Set(1, iType);
sl@0
    80
sl@0
    81
	User::LeaveIfError(iClient.Session().Send(ELogViewCreate, aArgs));
sl@0
    82
	CLogViewWindow* window = new(ELeave)
sl@0
    83
		CLogViewWindow(iClient.Session(), iViewId, KLogDefaultWindowSize,
sl@0
    84
		iLogViewChangeObserver, CActive::EPriorityIdle);
sl@0
    85
	
sl@0
    86
	delete iWindow;
sl@0
    87
	iWindow = window;
sl@0
    88
	iWindow->ConstructL(*iPackage);
sl@0
    89
sl@0
    90
	// The Log view observer receives all events from the log server. It then cascades them to an object owned by
sl@0
    91
	// the log window. In turn this object (CLogViewWindowChangeObserver) cascades them back to the log window.
sl@0
    92
	// Finally, the log window passes them back up to the client of the log engine, i.e aObserver.
sl@0
    93
	CLogViewObserver* observer = CLogViewObserver::NewL(*this, iClient, iWindow->ChangeObserver(), iViewId, Priority());
sl@0
    94
	delete iLogViewObserver;
sl@0
    95
	iLogViewObserver = observer;
sl@0
    96
	}
sl@0
    97
sl@0
    98
EXPORT_C TBool CLogView::FirstL(TRequestStatus& aStatus)
sl@0
    99
/** Moves the current position in the view to the first event. The first event 
sl@0
   100
is the most recent event.
sl@0
   101
sl@0
   102
This is an asynchronous request.
sl@0
   103
sl@0
   104
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   105
if the position in the view has been successfully moved; otherwise, one of 
sl@0
   106
the other system wide error codes.
sl@0
   107
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   108
EFalse, if there are no events in the view. */
sl@0
   109
	{
sl@0
   110
	return NavigateL(ELogNavigateFirst, aStatus);
sl@0
   111
	}
sl@0
   112
sl@0
   113
EXPORT_C TBool CLogView::LastL(TRequestStatus& aStatus)
sl@0
   114
/** Moves the current position in the view to the last event. The last event is 
sl@0
   115
the oldest event.
sl@0
   116
sl@0
   117
This is an asynchronous request.
sl@0
   118
sl@0
   119
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   120
if the position in the view has been successfully moved; otherwise, one of 
sl@0
   121
the other system wide error codes.
sl@0
   122
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   123
EFalse, if there are no events in the view. */
sl@0
   124
	{
sl@0
   125
	return NavigateL(ELogNavigateLast, aStatus);
sl@0
   126
	}
sl@0
   127
sl@0
   128
EXPORT_C TBool CLogView::NextL(TRequestStatus& aStatus)
sl@0
   129
/** Moves the current position in the view to the next event. The next event is 
sl@0
   130
always older than the current event, i.e. next implies movement in the first 
sl@0
   131
to last direction.
sl@0
   132
sl@0
   133
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   134
if the position in the view has been successfully moved; otherwise, one of 
sl@0
   135
the other system wide error codes.
sl@0
   136
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   137
EFalse, if there are no events in the view. */
sl@0
   138
	{
sl@0
   139
	return NavigateL(ELogNavigateForwards, aStatus);
sl@0
   140
	}
sl@0
   141
sl@0
   142
EXPORT_C TBool CLogView::PreviousL(TRequestStatus& aStatus)
sl@0
   143
/** Moves the current position in the view to the previous event. The previous 
sl@0
   144
event is always more recent than the current event, i.e. previous implies 
sl@0
   145
movement in the last to first direction.
sl@0
   146
sl@0
   147
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   148
if the position in the view has been successfully moved; otherwise, one of 
sl@0
   149
the other system wide error codes.
sl@0
   150
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   151
EFalse, if there are no events in the view. */
sl@0
   152
	{
sl@0
   153
	return NavigateL(ELogNavigateBackwards, aStatus);
sl@0
   154
	}
sl@0
   155
sl@0
   156
EXPORT_C TInt CLogView::CountL()
sl@0
   157
/** Gets the number of events in the view.
sl@0
   158
sl@0
   159
@return The number of events in the view. */
sl@0
   160
	{
sl@0
   161
	// Just return zero if the view isn't setup
sl@0
   162
	if	(!IsValid() && !LogViewRecordCount())
sl@0
   163
		{
sl@0
   164
		return 0;
sl@0
   165
		}
sl@0
   166
sl@0
   167
	// Ask the server the number of events in this view
sl@0
   168
	const TInt count = iClient.Session().Send(ELogViewCount, TIpcArgs(iViewId));
sl@0
   169
sl@0
   170
	User::LeaveIfError(count);
sl@0
   171
	return count;
sl@0
   172
	}
sl@0
   173
sl@0
   174
EXPORT_C void CLogView::SetFlagsL(TLogFlags aFlags)
sl@0
   175
/**
sl@0
   176
@capability Note For built-in event types, the required capability level is defined in
sl@0
   177
the event type's write access policy. */
sl@0
   178
	{
sl@0
   179
	// To preserve the same server side interface as an operation
sl@0
   180
	TPckgBuf<TLogClientServerData> data;
sl@0
   181
	data().iOperationType = ELogOperationViewSetFlags;
sl@0
   182
	data().iOperationId = KLogNullOperationId;
sl@0
   183
	//
sl@0
   184
	User::LeaveIfError(iClient.Session().Send(ELogViewOperationInitiate, TIpcArgs(&data,iViewId,aFlags)));
sl@0
   185
	}
sl@0
   186
sl@0
   187
TBool CLogView::NavigateL(TInt aPosition, TRequestStatus& aStatus)
sl@0
   188
	{
sl@0
   189
	__ASSERT_ALWAYS(!IsActive(), Panic(ELogAlreadyActive1));
sl@0
   190
	if (!IsValid() && !LogViewRecordCount())
sl@0
   191
		{
sl@0
   192
		return EFalse;
sl@0
   193
		}
sl@0
   194
	//
sl@0
   195
	const TLogNavigation navigationPosition = static_cast<TLogNavigation>(aPosition);
sl@0
   196
	const TBool requestIssued = iWindow->NavigateL(navigationPosition, iStatus);
sl@0
   197
	//
sl@0
   198
	if	(requestIssued)
sl@0
   199
		{
sl@0
   200
		Queue(aStatus);
sl@0
   201
		SetActive();
sl@0
   202
		// iValid is false if at time of SetFilterL there is no event.
sl@0
   203
		// If iWindow->NavigateL returns ETrue then there are always
sl@0
   204
		// events in the view.
sl@0
   205
		iValid = ETrue;
sl@0
   206
		}
sl@0
   207
	//
sl@0
   208
	return requestIssued;
sl@0
   209
	}
sl@0
   210
sl@0
   211
void CLogView::DoRunL()
sl@0
   212
	{
sl@0
   213
	if	(iStatus.Int() == KErrNone)
sl@0
   214
		ReadEventFromWindowL();
sl@0
   215
	}
sl@0
   216
sl@0
   217
void CLogView::DoCancel()
sl@0
   218
	{
sl@0
   219
	iWindow->Cancel();
sl@0
   220
	CLogActive::DoCancel();
sl@0
   221
	}
sl@0
   222
sl@0
   223
void CLogView::ReadEventFromWindowL()
sl@0
   224
	{
sl@0
   225
	CLogEvent* event = CLogEvent::NewL();
sl@0
   226
	delete iEvent;
sl@0
   227
	iEvent = event;
sl@0
   228
	iEvent->CopyL(iWindow->CurrsorEvent());
sl@0
   229
	}
sl@0
   230
sl@0
   231
void CLogView::ReawaitForChanges()
sl@0
   232
	{
sl@0
   233
	iLogViewObserver->Cancel();
sl@0
   234
	iLogViewObserver->RequestChanges();
sl@0
   235
	}
sl@0
   236
sl@0
   237
//
sl@0
   238
// The CLogViewWindow member has an observer to receive changes
sl@0
   239
// in events. If events are added to database after SetFilterL then
sl@0
   240
// iWindow would know about them.
sl@0
   241
TInt CLogView::LogViewRecordCount() const
sl@0
   242
	{
sl@0
   243
	if (iWindow)
sl@0
   244
		{
sl@0
   245
		return iWindow->ViewRecordCount();
sl@0
   246
		}
sl@0
   247
	return 0;
sl@0
   248
	}
sl@0
   249
sl@0
   250
sl@0
   251
sl@0
   252
sl@0
   253
sl@0
   254
sl@0
   255
sl@0
   256
sl@0
   257
sl@0
   258
sl@0
   259
sl@0
   260
sl@0
   261
sl@0
   262
sl@0
   263
sl@0
   264
sl@0
   265
//**********************************
sl@0
   266
// CLogViewEvent
sl@0
   267
//**********************************
sl@0
   268
sl@0
   269
CLogViewEvent::CLogViewEvent(CLogClient& aClient, TInt aPriority)
sl@0
   270
: CLogView(aClient, aPriority)
sl@0
   271
	{
sl@0
   272
	}
sl@0
   273
sl@0
   274
EXPORT_C CLogViewEvent::~CLogViewEvent()
sl@0
   275
/** Frees all resources owned by the object prior to its destruction. In particular, 
sl@0
   276
any outstanding asynchronous request is cancelled */
sl@0
   277
	{
sl@0
   278
	Cancel();
sl@0
   279
	}
sl@0
   280
sl@0
   281
void CLogViewEvent::ConstructL(MLogViewChangeObserver* aObserver)
sl@0
   282
	{
sl@0
   283
	CLogView::ConstructL(ELogViewTypeEvent, aObserver);
sl@0
   284
	}
sl@0
   285
sl@0
   286
EXPORT_C CLogViewEvent* CLogViewEvent::NewL(CLogClient& aClient, TInt aPriority)
sl@0
   287
	{
sl@0
   288
	CLogViewEvent* self = new(ELeave)CLogViewEvent(aClient, aPriority);
sl@0
   289
	CleanupStack::PushL(self);
sl@0
   290
	self->ConstructL();
sl@0
   291
	CleanupStack::Pop(self);
sl@0
   292
	return self;
sl@0
   293
	}
sl@0
   294
sl@0
   295
EXPORT_C CLogViewEvent* CLogViewEvent::NewL(CLogClient& aClient, MLogViewChangeObserver& aObserver, TInt aPriority)
sl@0
   296
	{
sl@0
   297
	CLogViewEvent* self = new(ELeave)CLogViewEvent(aClient, aPriority);
sl@0
   298
	CleanupStack::PushL(self);
sl@0
   299
	self->ConstructL(&aObserver);
sl@0
   300
	CleanupStack::Pop(self);
sl@0
   301
	return self;
sl@0
   302
	}
sl@0
   303
sl@0
   304
EXPORT_C TBool CLogViewEvent::SetFilterL(const CLogFilter& aFilter, TRequestStatus& aStatus)
sl@0
   305
/** Initialises or refreshes the event view defined by the specified filter.
sl@0
   306
sl@0
   307
The view can only be used after the request completes successfully.
sl@0
   308
sl@0
   309
@param aFilter The filter. 
sl@0
   310
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   311
if the view has been successfully initialised or refreshed;one of the other 
sl@0
   312
system wide error codes, otherwise. 
sl@0
   313
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   314
EFalse, if there are no events in the view. 
sl@0
   315
@capability Note None required.*/
sl@0
   316
	{
sl@0
   317
	CLogFilterList* list = new(ELeave)CLogFilterList;
sl@0
   318
	CleanupStack::PushL(list);
sl@0
   319
	list->AppendL(&aFilter);
sl@0
   320
	TBool result = SetFilterL(*list, aStatus);
sl@0
   321
	CleanupStack::PopAndDestroy(); // list
sl@0
   322
	return result;
sl@0
   323
	}
sl@0
   324
sl@0
   325
EXPORT_C TBool CLogViewEvent::SetFilterL(const CLogFilterList& aFilterList, TRequestStatus& aStatus)
sl@0
   326
/** Initialises or refreshes the event view defined by the set of specified filters.
sl@0
   327
sl@0
   328
The view can only be used after the request completes successfully.
sl@0
   329
sl@0
   330
@param aFilterList The set of filters. 
sl@0
   331
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   332
if the view has been successfully initialised or refreshed;one of the other 
sl@0
   333
system wide error codes, otherwise. 
sl@0
   334
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   335
EFalse, if there are no events in the view. 
sl@0
   336
@capability Note None required.  */
sl@0
   337
	{
sl@0
   338
	// Start maintenance of the database - ignore errors
sl@0
   339
	iMaintain->Start();
sl@0
   340
sl@0
   341
	// Package the parameters
sl@0
   342
	iPackage->SetLogFilterListL(aFilterList);
sl@0
   343
sl@0
   344
	// Setup the view
sl@0
   345
	const TInt count = iWindow->Setup(aFilterList, 0, ELogFilterConstructFilterByFilterFieldByField);
sl@0
   346
	User::LeaveIfError(count);
sl@0
   347
	iValid = count;
sl@0
   348
	ReawaitForChanges();
sl@0
   349
sl@0
   350
	if(count)
sl@0
   351
		{
sl@0
   352
		// Get the required event
sl@0
   353
		iValid = FirstL(aStatus);
sl@0
   354
		return iValid;
sl@0
   355
		}
sl@0
   356
	return EFalse;
sl@0
   357
	}
sl@0
   358
sl@0
   359
EXPORT_C TBool CLogViewEvent::SetFilterParseFilterByFilterL(const CLogFilterList& aFilterList, TRequestStatus& aStatus)
sl@0
   360
/**
sl@0
   361
@capability Note None required.  */
sl@0
   362
	{
sl@0
   363
	// Start maintenance of the database - ignore errors
sl@0
   364
	iMaintain->Start();
sl@0
   365
sl@0
   366
	// Package the parameters
sl@0
   367
	iPackage->SetLogFilterListL(aFilterList);
sl@0
   368
sl@0
   369
	// Setup the view
sl@0
   370
	const TInt count = iWindow->Setup(aFilterList, 0, ELogFilterConstructFieldByFieldFilterByFilter);
sl@0
   371
	User::LeaveIfError(count);
sl@0
   372
	iValid = count;
sl@0
   373
	ReawaitForChanges();
sl@0
   374
sl@0
   375
	if(count)
sl@0
   376
		{
sl@0
   377
		// Get the required event
sl@0
   378
		iValid = FirstL(aStatus);
sl@0
   379
		return iValid;
sl@0
   380
		}
sl@0
   381
	return EFalse;
sl@0
   382
	}
sl@0
   383
sl@0
   384
sl@0
   385
sl@0
   386
sl@0
   387
sl@0
   388
sl@0
   389
sl@0
   390
sl@0
   391
sl@0
   392
sl@0
   393
sl@0
   394
sl@0
   395
sl@0
   396
sl@0
   397
sl@0
   398
sl@0
   399
sl@0
   400
sl@0
   401
sl@0
   402
sl@0
   403
sl@0
   404
sl@0
   405
sl@0
   406
//**********************************
sl@0
   407
// CLogViewRecent
sl@0
   408
//**********************************
sl@0
   409
sl@0
   410
CLogViewRecent::CLogViewRecent(CLogClient& aClient, TInt aPriority)
sl@0
   411
: CLogView(aClient, aPriority)
sl@0
   412
	{
sl@0
   413
	}
sl@0
   414
sl@0
   415
EXPORT_C CLogViewRecent::~CLogViewRecent()
sl@0
   416
/** Frees resources owned by the object priot to its destruction. */
sl@0
   417
	{
sl@0
   418
	Cancel();
sl@0
   419
	delete iRemove;
sl@0
   420
	}
sl@0
   421
sl@0
   422
void CLogViewRecent::ConstructL(MLogViewChangeObserver* aObserver)
sl@0
   423
	{
sl@0
   424
	// Construct the view
sl@0
   425
	CLogView::ConstructL(ELogViewTypeRecent, aObserver);
sl@0
   426
sl@0
   427
	iRemove = new(ELeave) CLogViewRemoveEventClientOp(iClient.Session(), *iPackage, Priority());
sl@0
   428
	}
sl@0
   429
sl@0
   430
EXPORT_C CLogViewRecent* CLogViewRecent::NewL(CLogClient& aClient, TInt aPriority)
sl@0
   431
	{
sl@0
   432
	CLogViewRecent* self = new(ELeave) CLogViewRecent(aClient, aPriority);
sl@0
   433
	CleanupStack::PushL(self);
sl@0
   434
	self->ConstructL();
sl@0
   435
	CleanupStack::Pop(); // self
sl@0
   436
	return self;
sl@0
   437
	}
sl@0
   438
sl@0
   439
EXPORT_C CLogViewRecent* CLogViewRecent::NewL(CLogClient& aClient, MLogViewChangeObserver& aObserver, TInt aPriority)
sl@0
   440
	{
sl@0
   441
	CLogViewRecent* self = new(ELeave) CLogViewRecent(aClient, aPriority);
sl@0
   442
	CleanupStack::PushL(self);
sl@0
   443
	self->ConstructL(&aObserver);
sl@0
   444
	CleanupStack::Pop(self);
sl@0
   445
	return self;
sl@0
   446
	}
sl@0
   447
sl@0
   448
EXPORT_C TBool CLogViewRecent::SetRecentListL(TLogRecentList aList, TRequestStatus& aStatus)
sl@0
   449
/** Initialises or refreshes the view for the specified recent event list. This 
sl@0
   450
is an asynchronous request.
sl@0
   451
sl@0
   452
On successful completion, the view is positioned at the first, i.e. most recent, 
sl@0
   453
event within the recent event list.
sl@0
   454
sl@0
   455
@param aList The recent event list specifier. A value of KLogNullRecentList 
sl@0
   456
indicates that the view is to include events from all of the recent event 
sl@0
   457
lists.
sl@0
   458
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   459
if the view has been successfully initialised or refreshed; otherwise, one 
sl@0
   460
of the other system wide error codes.
sl@0
   461
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   462
EFalse, if there are no events in the view. 
sl@0
   463
@capability Note None required.  */
sl@0
   464
	{
sl@0
   465
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   466
	CleanupStack::PushL(filter);
sl@0
   467
	TBool result = SetRecentListL(aList, *filter, aStatus);
sl@0
   468
	CleanupStack::PopAndDestroy(); // filter
sl@0
   469
	return result;
sl@0
   470
	}
sl@0
   471
sl@0
   472
EXPORT_C TBool CLogViewRecent::SetRecentListL(TLogRecentList aList, const CLogFilter& aFilter, TRequestStatus& aStatus)
sl@0
   473
/** Initialises or refreshes the view for the specified recent event list, conforming 
sl@0
   474
to the specified filter. This is an asynchronous request.
sl@0
   475
sl@0
   476
On successful completion, the view is positioned at the first, i.e. most recent, 
sl@0
   477
event in the recent event list.
sl@0
   478
sl@0
   479
@param aList The recent event list specifier. A value of KLogNullRecentList 
sl@0
   480
indicates that the view is to include events from all of the recent event 
sl@0
   481
lists.
sl@0
   482
@param aFilter The filter.
sl@0
   483
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   484
if the view has been successfully initialised or refreshed; otherwise, one 
sl@0
   485
of the other system wide error codes.
sl@0
   486
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   487
EFalse, if there are no events in the view. 
sl@0
   488
@capability Note None required.  */
sl@0
   489
	{
sl@0
   490
	CLogFilterList* list = new(ELeave)CLogFilterList;
sl@0
   491
	CleanupStack::PushL(list);
sl@0
   492
	list->AppendL(&aFilter);
sl@0
   493
	TBool result = SetRecentListL(aList, *list, aStatus);
sl@0
   494
	CleanupStack::PopAndDestroy(); // list
sl@0
   495
	return result;
sl@0
   496
	}
sl@0
   497
sl@0
   498
EXPORT_C TBool CLogViewRecent::SetRecentListL(TLogRecentList aList, const CLogFilterList& aFilterList, TRequestStatus& aStatus)
sl@0
   499
/** Initialises or refreshes the view for the specified recent event list, conforming 
sl@0
   500
to the set of specified filters. This is an asynchronous request.
sl@0
   501
sl@0
   502
On successful completion, the view is positioned at the first, i.e. most recent, 
sl@0
   503
event in the recent event list.
sl@0
   504
sl@0
   505
@param aList The recent event list specifier. A value of KLogNullRecentList 
sl@0
   506
indicates that the view is to include events from all of the recent event 
sl@0
   507
lists.
sl@0
   508
@param aFilterList The set of filters.
sl@0
   509
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   510
if the view has been successfully initialised or refreshed; otherwise, one 
sl@0
   511
of the other system wide error codes.
sl@0
   512
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   513
EFalse, if there are no events in the view. 
sl@0
   514
@capability Note None required.  */
sl@0
   515
	{
sl@0
   516
	// Start maintenance of the database - ignore errors
sl@0
   517
	iMaintain->Start();
sl@0
   518
sl@0
   519
	// Package the parameters
sl@0
   520
	iPackage->SetLogFilterListL(aFilterList);
sl@0
   521
sl@0
   522
	// Setup the view
sl@0
   523
	TInt count = iWindow->Setup(aFilterList, aList, ELogFilterConstructFilterByFilterFieldByField);
sl@0
   524
	User::LeaveIfError(count);
sl@0
   525
	iValid = count;
sl@0
   526
	ReawaitForChanges();
sl@0
   527
sl@0
   528
	// Initialise list ids
sl@0
   529
	iRecentList = aList;
sl@0
   530
	iCurrentList = aList;
sl@0
   531
sl@0
   532
	// This receives the current recent list id from the server
sl@0
   533
	iCurrentListBuf() = iCurrentList;
sl@0
   534
	iData = &iCurrentListBuf;
sl@0
   535
sl@0
   536
	if(count)
sl@0
   537
		{
sl@0
   538
		// Get the required event
sl@0
   539
		iValid = FirstL(aStatus);
sl@0
   540
		return iValid;
sl@0
   541
		}
sl@0
   542
	return EFalse;
sl@0
   543
	}
sl@0
   544
sl@0
   545
EXPORT_C void CLogViewRecent::RemoveL(TLogId aId)
sl@0
   546
/** Removes the event with the specified unique event ID from the view. This does 
sl@0
   547
not delete the event from the main event log.
sl@0
   548
sl@0
   549
@param aId The unique event ID. 
sl@0
   550
@capability WriteDeviceData  */
sl@0
   551
	{
sl@0
   552
	User::LeaveIfError(iRemove->Start(iViewId, aId));
sl@0
   553
	iWindow->RemoveFromWindowIfPresentL(aId);
sl@0
   554
	}
sl@0
   555
sl@0
   556
EXPORT_C TBool CLogViewRecent::RemoveL(TRequestStatus& aStatus)
sl@0
   557
/** Removes the current event from its recent event list. This is an asynchronous 
sl@0
   558
request.
sl@0
   559
sl@0
   560
This does not delete the event from the main event log.
sl@0
   561
sl@0
   562
The function moves the current position in the view to the first, i.e. most 
sl@0
   563
recent, event.
sl@0
   564
sl@0
   565
Note that removing a recent event from a recent event list also removes all 
sl@0
   566
of its duplicates.
sl@0
   567
sl@0
   568
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   569
if the view has been successfully initialised or refreshed; otherwise, one 
sl@0
   570
of the other system wide error codes.
sl@0
   571
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   572
EFalse, if there are no events in the view. 
sl@0
   573
@capability WriteDeviceData  */
sl@0
   574
	{
sl@0
   575
	__ASSERT_DEBUG(IsValid(), Panic(ELogNotValid1));
sl@0
   576
	RemoveL(Event().Id());
sl@0
   577
	return FirstL(aStatus);
sl@0
   578
	}
sl@0
   579
sl@0
   580
EXPORT_C TBool CLogViewRecent::DuplicatesL(CLogViewDuplicate& aView, TRequestStatus& aStatus)
sl@0
   581
/** Refreshes the specified duplicate event view with the duplicates of the current 
sl@0
   582
event in the recent event list view. This is an asynchronous request.
sl@0
   583
sl@0
   584
On successful completion, the view is positioned at the first, i.e. most recent, 
sl@0
   585
event within the view.
sl@0
   586
sl@0
   587
@param aView The duplicates view to be refreshed.
sl@0
   588
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   589
if the view has been successfully refreshed; otherwise, one of the other system 
sl@0
   590
wide error codes.
sl@0
   591
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   592
EFalse, if there are no events in the view. 
sl@0
   593
@capability Note None required.  */
sl@0
   594
	{
sl@0
   595
	__ASSERT_ALWAYS(!IsActive(), Panic(ELogAlreadyActive5));
sl@0
   596
	return IsValid() && aView.SetEventL(Event().Id(), aStatus);
sl@0
   597
	}
sl@0
   598
sl@0
   599
EXPORT_C TBool CLogViewRecent::DuplicatesL(CLogViewDuplicate& aView, const CLogFilter& aFilter, TRequestStatus& aStatus)
sl@0
   600
/** Refreshes the specified duplicate event view with the duplicates of the current 
sl@0
   601
event in the recent event list view and conforming to the specified filter. 
sl@0
   602
This is an asynchronous request.
sl@0
   603
sl@0
   604
On successful completion, the view is positioned at the first, i.e. most recent, 
sl@0
   605
event within the view.
sl@0
   606
sl@0
   607
@param aView The duplicates view to be refreshed.
sl@0
   608
@param aFilter The filter.
sl@0
   609
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   610
if the view has been successfully refreshed; otherwise, one of the other system 
sl@0
   611
wide error codes.
sl@0
   612
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   613
EFalse, if there are no events in the view. 
sl@0
   614
@capability Note None required.*/
sl@0
   615
	{
sl@0
   616
	__ASSERT_ALWAYS(!IsActive(), Panic(ELogAlreadyActive6));
sl@0
   617
	return IsValid() && aView.SetEventL(Event().Id(), aFilter, aStatus);
sl@0
   618
	}
sl@0
   619
sl@0
   620
EXPORT_C TBool CLogViewRecent::DuplicatesL(CLogViewDuplicate& aView, const CLogFilterList& aFilterList, TRequestStatus& aStatus)
sl@0
   621
/** Refreshes the specified duplicate event view with the duplicates of the current 
sl@0
   622
event in the recent event list view and conforming to the set of specified 
sl@0
   623
filters. This is an asynchronous request.
sl@0
   624
sl@0
   625
On successful completion, the view is positioned at the first, i.e. most recent, 
sl@0
   626
event within the view.
sl@0
   627
sl@0
   628
@param aView The duplicates view to be refreshed.
sl@0
   629
@param aFilterList The set of filters.
sl@0
   630
@param aStatus The request status. On request completion, contains:KErrNone, 
sl@0
   631
if the view has been successfully refreshed; otherwise, one of the other system 
sl@0
   632
wide error codes.
sl@0
   633
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   634
EFalse, if there are no events in the view. 
sl@0
   635
@capability Note None required.*/
sl@0
   636
	{
sl@0
   637
	__ASSERT_ALWAYS(!IsActive(), Panic(ELogAlreadyActive7));
sl@0
   638
	return IsValid() && aView.SetEventL(Event().Id(), aFilterList, aStatus);
sl@0
   639
	}
sl@0
   640
sl@0
   641
EXPORT_C void CLogViewRecent::ClearDuplicatesL()
sl@0
   642
/**
sl@0
   643
@capability WriteDeviceData  */
sl@0
   644
	{
sl@0
   645
	__ASSERT_DEBUG(IsValid(), Panic(ELogNotValid3));
sl@0
   646
sl@0
   647
	// To preserve the same server side interface as an operation
sl@0
   648
	TPckgBuf<TLogClientServerData> data;
sl@0
   649
	data().iOperationType = ELogOperationViewClearDuplicates;
sl@0
   650
	data().iOperationId = KLogNullOperationId;
sl@0
   651
	//
sl@0
   652
	User::LeaveIfError(iClient.Session().Send(ELogViewOperationInitiate, TIpcArgs(&data,iViewId)));
sl@0
   653
	}
sl@0
   654
sl@0
   655
void CLogViewRecent::DoRunL()
sl@0
   656
	{
sl@0
   657
	// To fetch the event
sl@0
   658
	ReadEventFromWindowL();
sl@0
   659
sl@0
   660
	// A fix to maintain source compatibility
sl@0
   661
	iCurrentList = iCurrentListBuf();
sl@0
   662
	}
sl@0
   663
sl@0
   664
sl@0
   665
sl@0
   666
sl@0
   667
sl@0
   668
sl@0
   669
sl@0
   670
sl@0
   671
sl@0
   672
sl@0
   673
sl@0
   674
sl@0
   675
sl@0
   676
sl@0
   677
sl@0
   678
sl@0
   679
sl@0
   680
sl@0
   681
//**********************************
sl@0
   682
// CLogViewDuplicate
sl@0
   683
//**********************************
sl@0
   684
sl@0
   685
CLogViewDuplicate::CLogViewDuplicate(CLogClient& aClient, TInt aPriority)
sl@0
   686
: CLogView(aClient, aPriority)
sl@0
   687
	{
sl@0
   688
	}
sl@0
   689
sl@0
   690
EXPORT_C CLogViewDuplicate::~CLogViewDuplicate()
sl@0
   691
	{
sl@0
   692
	Cancel();
sl@0
   693
	delete iRemove;
sl@0
   694
	}
sl@0
   695
sl@0
   696
void CLogViewDuplicate::ConstructL(MLogViewChangeObserver* aObserver)
sl@0
   697
	{
sl@0
   698
	CLogView::ConstructL(ELogViewTypeDuplicate, aObserver);
sl@0
   699
sl@0
   700
	iRemove = new(ELeave) CLogViewRemoveEventClientOp(iClient.Session(), *iPackage, Priority());
sl@0
   701
	}
sl@0
   702
sl@0
   703
EXPORT_C CLogViewDuplicate* CLogViewDuplicate::NewL(CLogClient& aClient, TInt aPriority)
sl@0
   704
	{
sl@0
   705
	CLogViewDuplicate* self = new(ELeave)CLogViewDuplicate(aClient, aPriority);
sl@0
   706
	CleanupStack::PushL(self);
sl@0
   707
	self->ConstructL();
sl@0
   708
	CleanupStack::Pop();
sl@0
   709
	return self;
sl@0
   710
	}
sl@0
   711
sl@0
   712
EXPORT_C CLogViewDuplicate* CLogViewDuplicate::NewL(CLogClient& aClient, MLogViewChangeObserver& aObserver, TInt aPriority)
sl@0
   713
	{
sl@0
   714
	CLogViewDuplicate* self = new(ELeave) CLogViewDuplicate(aClient, aPriority);
sl@0
   715
	CleanupStack::PushL(self);
sl@0
   716
	self->ConstructL(&aObserver);
sl@0
   717
	CleanupStack::Pop(self);
sl@0
   718
	return self;
sl@0
   719
	}
sl@0
   720
sl@0
   721
TBool CLogViewDuplicate::SetEventL(TLogId aId, TRequestStatus& aStatus)
sl@0
   722
	{
sl@0
   723
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   724
	CleanupStack::PushL(filter);
sl@0
   725
	TBool result = SetEventL(aId, *filter, aStatus);
sl@0
   726
	CleanupStack::PopAndDestroy(); // filter
sl@0
   727
	return result;
sl@0
   728
	}
sl@0
   729
sl@0
   730
TBool CLogViewDuplicate::SetEventL(TLogId aId, const CLogFilter& aFilter, TRequestStatus& aStatus)
sl@0
   731
	{
sl@0
   732
	CLogFilterList* list = new(ELeave)CLogFilterList;
sl@0
   733
	CleanupStack::PushL(list);
sl@0
   734
	list->AppendL(&aFilter);
sl@0
   735
	TBool result = SetEventL(aId, *list, aStatus);
sl@0
   736
	CleanupStack::PopAndDestroy(); // list
sl@0
   737
	return result;
sl@0
   738
	}
sl@0
   739
sl@0
   740
TBool CLogViewDuplicate::SetEventL(TLogId aId, const CLogFilterList& aFilterList, TRequestStatus& aStatus)
sl@0
   741
	{
sl@0
   742
	// Start maintenance of the database - ignore errors
sl@0
   743
	iMaintain->Start();
sl@0
   744
sl@0
   745
	// Package the parameters
sl@0
   746
	iPackage->SetLogFilterListL(aFilterList);
sl@0
   747
sl@0
   748
	// Setup the view
sl@0
   749
	TInt count = iWindow->Setup(aFilterList, aId, ELogFilterConstructFilterByFilterFieldByField);
sl@0
   750
	User::LeaveIfError(count);
sl@0
   751
	iValid = count;
sl@0
   752
	iSourceId = aId;
sl@0
   753
	ReawaitForChanges();
sl@0
   754
sl@0
   755
	if(count)
sl@0
   756
		{
sl@0
   757
		// Get the required event
sl@0
   758
		iValid = FirstL(aStatus);
sl@0
   759
		return iValid;
sl@0
   760
		}
sl@0
   761
	return EFalse;
sl@0
   762
	}
sl@0
   763
sl@0
   764
EXPORT_C void CLogViewDuplicate::RemoveL(TLogId aId)
sl@0
   765
/** Removes the event with the specified unique event ID from the view. This does 
sl@0
   766
not delete the event from the main event log.
sl@0
   767
sl@0
   768
@param aId The unique event ID. 
sl@0
   769
@capability WriteDeviceData  */
sl@0
   770
	{
sl@0
   771
	// Note: Duplicate views reset themselves
sl@0
   772
	__ASSERT_DEBUG(IsValid(), Panic(ELogNotValid2));
sl@0
   773
	User::LeaveIfError(iRemove->Start(iViewId, aId));
sl@0
   774
	iWindow->RemoveFromWindowIfPresentL(aId);
sl@0
   775
	}
sl@0
   776
sl@0
   777
EXPORT_C TBool CLogViewDuplicate::RemoveL(TRequestStatus& aStatus)
sl@0
   778
/** Removes the current event from the duplicate list. This is an asynchronous 
sl@0
   779
request.
sl@0
   780
sl@0
   781
This does not delete the event from the main event log.
sl@0
   782
sl@0
   783
The function moves the current position in the view to the first, i.e. most 
sl@0
   784
recent, event.
sl@0
   785
sl@0
   786
@param aStatus The request status. On request completion, contains: KErrNone, 
sl@0
   787
if the view has been successfully initialised or refreshed; otherwise, one 
sl@0
   788
of the other system wide error codes.
sl@0
   789
@return ETrue, if the function has successfully issued the asynchronous request. 
sl@0
   790
EFalse, if there are no events in the view. 
sl@0
   791
@capability WriteDeviceData  */
sl@0
   792
	{
sl@0
   793
	RemoveL(Event().Id());
sl@0
   794
	return FirstL(aStatus);
sl@0
   795
	}