os/persistentdata/loggingservices/eventlogger/LogCli/src/logclientop.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogCli/src/logclientop.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,558 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include "logclientop.h"
    1.20 +
    1.21 +// User includes
    1.22 +#include "logservcli.h"
    1.23 +
    1.24 +
    1.25 +CLogClientOp::CLogClientOp(RLogSession& aSession, CLogPackage& aPackage, TLogOperationType aType, TInt aPriority)
    1.26 +:	CActive(aPriority), iPackage(aPackage), iSession(aSession)
    1.27 +//
    1.28 +//	Base client side operation
    1.29 +//
    1.30 +	{
    1.31 +	iData().iOperationType = aType;
    1.32 +	CActiveScheduler::Add(this);
    1.33 +	}
    1.34 +
    1.35 +CLogClientOp::~CLogClientOp()
    1.36 +	{
    1.37 +	Cancel();
    1.38 +	}
    1.39 +
    1.40 +void CLogClientOp::Start(TRequestStatus& aObserver)
    1.41 +//
    1.42 +//	Start the ball rolling - InitiateRequestToServerL called in RunL so it can leave
    1.43 +//
    1.44 +	{
    1.45 +	iObserver = &aObserver;
    1.46 +	aObserver = KRequestPending;
    1.47 +
    1.48 +	// Just complete ourselves
    1.49 +	TRequestStatus* status = &iStatus;
    1.50 +	User::RequestComplete(status, KErrNone);
    1.51 +	SetActive();
    1.52 +	}
    1.53 +
    1.54 +TInt CLogClientOp::Start()
    1.55 +//
    1.56 +//	Synchronous way of running operations
    1.57 +//
    1.58 +	{
    1.59 +	TInt result = KErrNone;
    1.60 +	TRAP(result, result = DoStartL());
    1.61 +	iData().iOperationId = KLogNullOperationId;
    1.62 +	return result;
    1.63 +	}
    1.64 +
    1.65 +TInt CLogClientOp::DoStartL()
    1.66 +	{
    1.67 +	iData().iOperationId = iSession.AllocateIdOperation();
    1.68 +	InitiateRequestToServerL();
    1.69 +	User::WaitForRequest(iStatus);
    1.70 +	//We have an asynchronous request completed synchronously. 
    1.71 +	//We have to do some iStatus cleanups.
    1.72 +	TRequestStatus status;//New TRequestStatus local variable. The default constructor will set iFlags data memebr to 0.
    1.73 +	status = iStatus.Int();//Only iStatus data member getzs initialized.
    1.74 +	iStatus = status;//Return back the same iStatus value but with iFlags data memeber cleared.
    1.75 +	User::LeaveIfError(iStatus.Int());
    1.76 +
    1.77 +	TInt result = iStatus.Int();
    1.78 +	CompleteL(result);
    1.79 +	iData().iOperationId = KLogNullOperationId;
    1.80 +	return result;
    1.81 +	}
    1.82 +
    1.83 +void CLogClientOp::RunL()
    1.84 +	{
    1.85 +	LOGTEXT2("CLogClientOp::RunL(%d)", iStatus.Int());
    1.86 +
    1.87 +	User::LeaveIfError(iStatus.Int());
    1.88 +
    1.89 +	// Set ourselves up - make the actual request?
    1.90 +	if (iData().iOperationId == KLogNullOperationId)
    1.91 +		{
    1.92 +		// Get the id of the operation
    1.93 +		iData().iOperationId = iSession.AllocateIdOperation();
    1.94 +
    1.95 +		InitiateRequestToServerL();
    1.96 +		SetActive();
    1.97 +		}
    1.98 +	else
    1.99 +		{
   1.100 +		// Finish off the request
   1.101 +		iData().iOperationId = KLogNullOperationId;
   1.102 +		TInt result = iStatus.Int();
   1.103 +		CompleteL(result);
   1.104 +		User::RequestComplete(iObserver, result);
   1.105 +		}
   1.106 +
   1.107 +	LOGTEXT("CLogClientOp::RunL() - end");
   1.108 +	}
   1.109 +
   1.110 +void CLogClientOp::DoCancel()
   1.111 +//
   1.112 +//	Cancel the request to the server if we initiated one
   1.113 +//
   1.114 +	{
   1.115 +	LOGTEXT2("CLogClientOp::DoCancel() - OperationId: %d", iData().iOperationId);
   1.116 +
   1.117 +	// Cancel this operation if we have an id
   1.118 +	if (iData().iOperationId > 0)
   1.119 +		{
   1.120 +		iSession.Send(ELogOperationCancel, TIpcArgs(&iData));
   1.121 +		//
   1.122 +		iData().iOperationId = KLogNullOperationId;
   1.123 +		}
   1.124 +
   1.125 +	User::RequestComplete(iObserver, KErrCancel);
   1.126 +	LOGTEXT("CLogClientOp::DoCancel() - end");
   1.127 +	}
   1.128 +
   1.129 +// Just complete the observer on error
   1.130 +TInt CLogClientOp::RunError(TInt aError)
   1.131 +	{
   1.132 +	iData().iOperationId = KLogNullOperationId;
   1.133 +	User::RequestComplete(iObserver, aError);
   1.134 +	return KErrNone;
   1.135 +	}
   1.136 +
   1.137 +void CLogClientOp::CompleteL(TInt& /*aCompletionCode*/)
   1.138 +//
   1.139 +//	By default operations don't do anything after completion
   1.140 +//
   1.141 +	{
   1.142 +	}
   1.143 +
   1.144 +void CLogClientOp::FetchResultFromServerL(TInt aResult)
   1.145 +	{
   1.146 +	iPackage.ResizeL(aResult);
   1.147 +	TPtr8 ptr(iPackage.Ptr());
   1.148 +
   1.149 +	User::LeaveIfError(iSession.Send(ELogOperationGetResult, TIpcArgs(&iData,&ptr,ptr.Length())));
   1.150 +	}
   1.151 +
   1.152 +/** 
   1.153 + * Initialise the data slot values
   1.154 + */
   1.155 +void CLogClientOp::SetDataSlot1(TInt aValue)
   1.156 +	{
   1.157 +	iData().iDataSlot1 = aValue;
   1.158 +	}
   1.159 +
   1.160 +
   1.161 +
   1.162 +
   1.163 +
   1.164 +
   1.165 +
   1.166 +CLogAddEventClientOp::CLogAddEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.167 +:	CLogClientOp(aSession, aPackage, ELogOperationEventAdd, aPriority)
   1.168 +	{
   1.169 +	}
   1.170 +
   1.171 +void CLogAddEventClientOp::Start(CLogEvent& aEvent, TRequestStatus& aObserver)
   1.172 +	{
   1.173 +	iEvent = &aEvent;
   1.174 +	CLogClientOp::Start(aObserver);
   1.175 +	}
   1.176 +
   1.177 +void CLogAddEventClientOp::InitiateRequestToServerL()
   1.178 +	{
   1.179 +	iPackage.SetLogEventL(*iEvent);
   1.180 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus);
   1.181 +	}
   1.182 +
   1.183 +void CLogAddEventClientOp::CompleteL(TInt& aResult)
   1.184 +	{
   1.185 +	FetchResultFromServerL(aResult);
   1.186 +	iPackage.GetLogEventL(*iEvent);
   1.187 +	}
   1.188 +
   1.189 +
   1.190 +
   1.191 +
   1.192 +
   1.193 +
   1.194 +
   1.195 +CLogChangeEventClientOp::CLogChangeEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.196 +:	CLogClientOp(aSession, aPackage, ELogOperationEventChange, aPriority)
   1.197 +	{
   1.198 +	}
   1.199 +
   1.200 +void CLogChangeEventClientOp::Start(const CLogEvent& aEvent, TRequestStatus& aObserver)
   1.201 +	{
   1.202 +	iEvent = &aEvent;
   1.203 +	CLogClientOp::Start(aObserver);
   1.204 +	}
   1.205 +
   1.206 +void CLogChangeEventClientOp::InitiateRequestToServerL()
   1.207 +	{
   1.208 +	iPackage.SetLogEventL(*iEvent);
   1.209 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus);
   1.210 +	}
   1.211 +
   1.212 +
   1.213 +
   1.214 +
   1.215 +
   1.216 +
   1.217 +CLogGetEventClientOp::CLogGetEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.218 +:	CLogClientOp(aSession, aPackage, ELogOperationEventGet, aPriority)
   1.219 +	{
   1.220 +	}
   1.221 +
   1.222 +void CLogGetEventClientOp::Start(CLogEvent& aEvent, TRequestStatus& aObserver)
   1.223 +	{
   1.224 +	iEvent = &aEvent;
   1.225 +	CLogClientOp::Start(aObserver);
   1.226 +	}
   1.227 +
   1.228 +void CLogGetEventClientOp::InitiateRequestToServerL()
   1.229 +	{
   1.230 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iEvent->Id()), iStatus);
   1.231 +	}
   1.232 +
   1.233 +void CLogGetEventClientOp::CompleteL(TInt& aResult)
   1.234 +	{
   1.235 +	FetchResultFromServerL(aResult);
   1.236 +	iPackage.GetLogEventL(*iEvent);
   1.237 +	}
   1.238 +
   1.239 +
   1.240 +
   1.241 +
   1.242 +
   1.243 +
   1.244 +
   1.245 +CLogDeleteEventClientOp::CLogDeleteEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.246 +:	CLogClientOp(aSession, aPackage, ELogOperationEventDelete, aPriority)
   1.247 +	{
   1.248 +	}
   1.249 +
   1.250 +void CLogDeleteEventClientOp::Start(TLogId aId, TRequestStatus& aObserver)
   1.251 +	{
   1.252 +	iId = aId;
   1.253 +	CLogClientOp::Start(aObserver);
   1.254 +	}
   1.255 +
   1.256 +void CLogDeleteEventClientOp::InitiateRequestToServerL()
   1.257 +	{
   1.258 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iId), iStatus);
   1.259 +	}
   1.260 +
   1.261 +
   1.262 +
   1.263 +
   1.264 +
   1.265 +
   1.266 +
   1.267 +
   1.268 +
   1.269 +CLogAddTypeClientOp::CLogAddTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.270 +:	CLogClientOp(aSession, aPackage, ELogOperationTypeAdd, aPriority)
   1.271 +	{
   1.272 +	}
   1.273 +
   1.274 +void CLogAddTypeClientOp::Start(const CLogEventType& aEventType, TRequestStatus& aObserver)
   1.275 +	{
   1.276 +	iEventType = &aEventType;
   1.277 +	CLogClientOp::Start(aObserver);
   1.278 +	}
   1.279 +
   1.280 +void CLogAddTypeClientOp::InitiateRequestToServerL()
   1.281 +	{
   1.282 +	iPackage.SetLogEventTypeL(*iEventType);
   1.283 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus);
   1.284 +	}
   1.285 +
   1.286 +
   1.287 +
   1.288 +
   1.289 +
   1.290 +
   1.291 +
   1.292 +
   1.293 +CLogChangeTypeClientOp::CLogChangeTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.294 +:	CLogClientOp(aSession, aPackage, ELogOperationTypeChange, aPriority)
   1.295 +	{
   1.296 +	}
   1.297 +
   1.298 +void CLogChangeTypeClientOp::Start(const CLogEventType& aEventType, TRequestStatus& aObserver)
   1.299 +	{
   1.300 +	iEventType = &aEventType;
   1.301 +	CLogClientOp::Start(aObserver);
   1.302 +	}
   1.303 +
   1.304 +void CLogChangeTypeClientOp::InitiateRequestToServerL()
   1.305 +	{
   1.306 +	iPackage.SetLogEventTypeL(*iEventType);
   1.307 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus);
   1.308 +	}
   1.309 +
   1.310 +
   1.311 +
   1.312 +
   1.313 +
   1.314 +
   1.315 +
   1.316 +CLogGetTypeClientOp::CLogGetTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.317 +:	CLogClientOp(aSession, aPackage, ELogOperationTypeGet, aPriority)
   1.318 +	{
   1.319 +	}
   1.320 +
   1.321 +void CLogGetTypeClientOp::Start(CLogEventType& aEventType, TRequestStatus& aObserver)
   1.322 +	{
   1.323 +	iEventType = &aEventType;
   1.324 +	CLogClientOp::Start(aObserver);
   1.325 +	}
   1.326 +
   1.327 +void CLogGetTypeClientOp::InitiateRequestToServerL()
   1.328 +	{
   1.329 +	TIpcArgs args(&iData, iEventType->Uid().iUid);
   1.330 +	iSession.Send(ELogOperationInitiate, args, iStatus);
   1.331 +	}
   1.332 +
   1.333 +void CLogGetTypeClientOp::CompleteL(TInt& aResult)
   1.334 +	{
   1.335 +	FetchResultFromServerL(aResult);
   1.336 +	iPackage.GetLogEventTypeL(*iEventType);
   1.337 +	}
   1.338 +
   1.339 +
   1.340 +
   1.341 +
   1.342 +
   1.343 +
   1.344 +
   1.345 +
   1.346 +CLogDeleteTypeClientOp::CLogDeleteTypeClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.347 +:	CLogClientOp(aSession, aPackage, ELogOperationTypeDelete, aPriority)
   1.348 +	{
   1.349 +	}
   1.350 +
   1.351 +void CLogDeleteTypeClientOp::Start(TUid aUid, TRequestStatus& aObserver)
   1.352 +	{
   1.353 +	iUid = aUid;
   1.354 +	CLogClientOp::Start(aObserver);
   1.355 +	}
   1.356 +
   1.357 +void CLogDeleteTypeClientOp::InitiateRequestToServerL()
   1.358 +	{
   1.359 +	TIpcArgs args(&iData, iUid.iUid);
   1.360 +	iSession.Send(ELogOperationInitiate, args, iStatus);
   1.361 +	}
   1.362 +
   1.363 +
   1.364 +
   1.365 +
   1.366 +
   1.367 +
   1.368 +
   1.369 +
   1.370 +CLogGetConfigClientOp::CLogGetConfigClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.371 +:	CLogClientOp(aSession, aPackage, ELogOperationConfigGet, aPriority)
   1.372 +	{
   1.373 +	}
   1.374 +
   1.375 +void CLogGetConfigClientOp::Start(TLogConfig& aConfig, TRequestStatus& aObserver)
   1.376 +	{
   1.377 +	iConfig = &aConfig;
   1.378 +	CLogClientOp::Start(aObserver);
   1.379 +	}
   1.380 +
   1.381 +void CLogGetConfigClientOp::InitiateRequestToServerL()
   1.382 +	{
   1.383 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData), iStatus);
   1.384 +	}
   1.385 +
   1.386 +void CLogGetConfigClientOp::CompleteL(TInt& aResult)
   1.387 +	{
   1.388 +	FetchResultFromServerL(aResult);
   1.389 +	iPackage.GetLogConfigL(*iConfig);
   1.390 +	}
   1.391 +
   1.392 +
   1.393 +
   1.394 +
   1.395 +
   1.396 +
   1.397 +
   1.398 +
   1.399 +
   1.400 +CLogChangeConfigClientOp::CLogChangeConfigClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.401 +:	CLogClientOp(aSession, aPackage, ELogOperationConfigChange, aPriority)
   1.402 +	{
   1.403 +	}
   1.404 +
   1.405 +void CLogChangeConfigClientOp::Start(const TLogConfig& aConfig, TRequestStatus& aObserver)
   1.406 +	{
   1.407 +	iConfig = &aConfig;
   1.408 +	CLogClientOp::Start(aObserver);
   1.409 +	}
   1.410 +
   1.411 +void CLogChangeConfigClientOp::InitiateRequestToServerL()
   1.412 +	{
   1.413 +	iPackage.SetLogConfigL(*iConfig);
   1.414 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, &iPackage.Ptr()), iStatus);
   1.415 +	}
   1.416 +
   1.417 +
   1.418 +
   1.419 +
   1.420 +
   1.421 +
   1.422 +
   1.423 +
   1.424 +
   1.425 +CLogClearLogClientOp::CLogClearLogClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority) :
   1.426 +	CLogClientOp(aSession, aPackage, ELogOperationClearLog, aPriority)
   1.427 +	{
   1.428 +	}
   1.429 +
   1.430 +void CLogClearLogClientOp::Start(const TTime& aDate, TRequestStatus& aObserver
   1.431 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
   1.432 +		, TSimId aSimId
   1.433 +#endif		
   1.434 +		)
   1.435 +	{
   1.436 +	iDate = aDate; // UTC
   1.437 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
   1.438 +	iSimId = aSimId;
   1.439 +#endif	
   1.440 +	CLogClientOp::Start(aObserver);
   1.441 +	}
   1.442 +
   1.443 +void CLogClearLogClientOp::InitiateRequestToServerL()
   1.444 +	{
   1.445 +	const TInt64 dateVal(iDate.Int64());
   1.446 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
   1.447 +	TIpcArgs args(&iData, I64LOW(dateVal), I64HIGH(dateVal), iSimId);
   1.448 +#else
   1.449 +	TIpcArgs args(&iData, I64LOW(dateVal), I64HIGH(dateVal));
   1.450 +#endif
   1.451 +	iSession.Send(ELogOperationInitiate, args, iStatus);
   1.452 +	}
   1.453 +
   1.454 +
   1.455 +
   1.456 +
   1.457 +
   1.458 +
   1.459 +
   1.460 +
   1.461 +CLogClearRecentClientOp::CLogClearRecentClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.462 +:	CLogClientOp(aSession, aPackage, ELogOperationClearRecent, aPriority)
   1.463 +	{
   1.464 +	}
   1.465 +
   1.466 +void CLogClearRecentClientOp::Start(TLogRecentList aList, TRequestStatus& aObserver
   1.467 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
   1.468 +		, TSimId aSimId
   1.469 +#endif		
   1.470 +		)
   1.471 +	{
   1.472 +	iList = aList;
   1.473 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
   1.474 +	iSimId = aSimId;
   1.475 +#endif	
   1.476 +	CLogClientOp::Start(aObserver);
   1.477 +	}
   1.478 +
   1.479 +void CLogClearRecentClientOp::InitiateRequestToServerL()
   1.480 +	{
   1.481 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
   1.482 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iList, iSimId), iStatus);
   1.483 +#else
   1.484 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData, iList), iStatus);
   1.485 +#endif
   1.486 +	}
   1.487 +
   1.488 +
   1.489 +
   1.490 +
   1.491 +
   1.492 +
   1.493 +
   1.494 +CLogMaintainClientOp::CLogMaintainClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.495 +:	CLogClientOp(aSession, aPackage, ELogOperationMaintain, aPriority)
   1.496 +	{
   1.497 +	}
   1.498 +
   1.499 +void CLogMaintainClientOp::InitiateRequestToServerL()
   1.500 +	{
   1.501 +	iSession.Send(ELogOperationInitiate, TIpcArgs(&iData), iStatus);
   1.502 +	}
   1.503 +
   1.504 +
   1.505 +
   1.506 +
   1.507 +
   1.508 +
   1.509 +
   1.510 +
   1.511 +CLogViewSetupClientOp::CLogViewSetupClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.512 +:	CLogClientOp(aSession, aPackage, ELogOperationViewSetup, aPriority)
   1.513 +	{
   1.514 +	}
   1.515 +
   1.516 +TInt CLogViewSetupClientOp::Start(TLogViewId aViewId, const CLogFilterList& aFilterList, TInt aParam, TLogFilterConstructionType aFilterConstructionType)
   1.517 +	{
   1.518 +	// Synchronous!
   1.519 +	iViewId = aViewId;
   1.520 +	iFilterList = &aFilterList;
   1.521 +	iParam = aParam;
   1.522 +	SetDataSlot1(aFilterConstructionType);
   1.523 +	//
   1.524 +	return CLogClientOp::Start();
   1.525 +	}
   1.526 +
   1.527 +void CLogViewSetupClientOp::InitiateRequestToServerL()
   1.528 +	{
   1.529 +	TIpcArgs args (&iData, iViewId, &iPackage.Ptr(), iParam);
   1.530 +	iSession.Send(ELogViewOperationInitiate, args, iStatus);
   1.531 +	}
   1.532 +
   1.533 +
   1.534 +
   1.535 +
   1.536 +
   1.537 +
   1.538 +
   1.539 +CLogViewRemoveEventClientOp::CLogViewRemoveEventClientOp(RLogSession& aSession, CLogPackage& aPackage, TInt aPriority)
   1.540 +:	CLogClientOp(aSession, aPackage, ELogOperationViewRemoveEvent, aPriority)
   1.541 +	{
   1.542 +	}
   1.543 +
   1.544 +TInt CLogViewRemoveEventClientOp::Start(TLogViewId aViewId, TLogId aId)
   1.545 +	{
   1.546 +	// Synchronous!
   1.547 +	iViewId = aViewId;
   1.548 +	iId = aId;
   1.549 +	return CLogClientOp::Start();
   1.550 +	}
   1.551 +
   1.552 +void CLogViewRemoveEventClientOp::InitiateRequestToServerL()
   1.553 +	{
   1.554 +	TIpcArgs args(&iData, iViewId, iId, 0);
   1.555 +	iSession.Send(ELogViewOperationInitiate, args, iStatus);
   1.556 +	}
   1.557 +
   1.558 +
   1.559 +
   1.560 +
   1.561 +