os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServOperationFactory.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/src/LogServOperationFactory.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,168 @@
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 +// LOGSERVOPERATIONFACTORY.H
1.18 +//
1.19 +//
1.20 +
1.21 +#include "LogServOperationFactory.h"
1.22 +
1.23 +// User includes
1.24 +#include "logservpanic.h"
1.25 +#include "LogServOperations.h"
1.26 +#include "LogServView.h"
1.27 +
1.28 +
1.29 +/////////////////////////////////////////////////////////////////////////////////////////
1.30 +// -----> LogServFactory (source)
1.31 +/////////////////////////////////////////////////////////////////////////////////////////
1.32 +
1.33 +CLogServOperationBase* LogServFactory::NewOperationL(const TLogClientServerData& aCliServData,
1.34 + MLogServTaskInterface& aTaskInterface,
1.35 + MLogServOperationManager& aOperationManager,
1.36 + const RMessage2& aMessage,
1.37 + CLogPackage& aLogPackage,
1.38 + TLogServSessionId aSessionId)
1.39 + {
1.40 + // The operations are all owned by the operation queue/manager as soon
1.41 + // as they are contructed (since they are all members of a queue).
1.42 + switch(aCliServData.iOperationType)
1.43 + {
1.44 + case ELogOperationEventAdd: // security checked in CLogAddEvent::StartL
1.45 + return new(ELeave) CLogServOpEventAdd(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.46 + aCliServData, aSessionId);
1.47 + case ELogOperationEventGet: // security checked in CLogGetEvent::DoRunL
1.48 + return new(ELeave) CLogServOpEventGet(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.49 + aCliServData, aSessionId);
1.50 + case ELogOperationEventChange: // security checked in CLogChangeEvent::DoChangeL
1.51 + return new(ELeave) CLogServOpEventChange(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.52 + aCliServData, aSessionId);
1.53 + case ELogOperationEventDelete: // security checked in CLogDeleteEvent::DoRunL
1.54 + return new(ELeave) CLogServOpEventDelete(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.55 + aCliServData, aSessionId);
1.56 + case ELogOperationTypeAdd:
1.57 + if(aMessage.HasCapability(ECapabilityWriteDeviceData))
1.58 + {
1.59 + return new(ELeave) CLogServOpTypeAdd(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.60 + aCliServData, aSessionId);
1.61 + }
1.62 + break;
1.63 + case ELogOperationTypeGet: // no security check
1.64 + return new(ELeave) CLogServOpTypeGet(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.65 + aCliServData, aSessionId);
1.66 + case ELogOperationTypeChange:
1.67 + if(aMessage.HasCapability(ECapabilityWriteDeviceData))
1.68 + {
1.69 + return new(ELeave) CLogServOpTypeChange(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.70 + aCliServData, aSessionId);
1.71 + }
1.72 + break;
1.73 + case ELogOperationTypeDelete:
1.74 + if(aMessage.HasCapability(ECapabilityWriteDeviceData))
1.75 + {
1.76 + return new(ELeave) CLogServOpTypeDelete(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.77 + aCliServData, aSessionId);
1.78 + }
1.79 + break;
1.80 + case ELogOperationClearLog:
1.81 + if(aMessage.HasCapability(ECapabilityWriteDeviceData))
1.82 + {
1.83 + return new(ELeave) CLogServOpClearLog(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.84 + aCliServData, aSessionId);
1.85 + }
1.86 + break;
1.87 + case ELogOperationClearRecent:
1.88 + if(aMessage.HasCapability(ECapabilityWriteDeviceData))
1.89 + {
1.90 + return new(ELeave) CLogServOpClearRecent(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.91 + aCliServData, aSessionId);
1.92 + }
1.93 + break;
1.94 + case ELogOperationConfigGet: // no security check
1.95 + return new(ELeave) CLogServOpConfigGet(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.96 + aCliServData, aSessionId);
1.97 + case ELogOperationConfigChange:
1.98 + if(aMessage.HasCapability(ECapabilityWriteDeviceData))
1.99 + {
1.100 + return new(ELeave) CLogServOpConfigChange(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.101 + aCliServData, aSessionId);
1.102 + }
1.103 + break;
1.104 + case ELogOperationMaintain: // no security check
1.105 + return new(ELeave) CLogServOpMaintenance(aTaskInterface, aOperationManager, aMessage, aLogPackage,
1.106 + aCliServData, aSessionId);
1.107 + default:
1.108 + ::PanicClientL(aMessage, ELogServFactoryUnrecognizedOperationType);
1.109 + break;
1.110 + }
1.111 +
1.112 + // clients who don't have the required capability need to be informed.
1.113 + User::Leave(KErrPermissionDenied);
1.114 + return NULL;
1.115 + }
1.116 +
1.117 +CLogServOperationBase* LogServFactory::NewViewOperationL(const TLogClientServerData& aCliServData,
1.118 + MLogServTaskInterface& aTaskInterface,
1.119 + MLogServOperationManager& aOperationManager,
1.120 + const RMessage2& aMessage,
1.121 + CLogPackage& aLogPackage,
1.122 + TLogServSessionId aSessionId,
1.123 + CLogServViewBase& aView)
1.124 + {
1.125 + // The operations are all owned by the operation queue/manager as soon
1.126 + // as they are contructed (since they are all members of a queue).
1.127 + switch(aCliServData.iOperationType)
1.128 + {
1.129 + case ELogOperationViewSetup:
1.130 + return new(ELeave) CLogServOpViewSetup(aTaskInterface, aOperationManager, aMessage, aLogPackage, aView,
1.131 + aCliServData, aSessionId);
1.132 + case ELogOperationViewRemoveEvent:
1.133 + return new(ELeave) CLogServOpViewEventRemove(aTaskInterface, aOperationManager, aMessage, aLogPackage, aView,
1.134 + aCliServData, aSessionId);
1.135 + case ELogOperationViewClearDuplicates:
1.136 + return new(ELeave) CLogServOpViewClearDuplicates(aTaskInterface, aOperationManager, aMessage, aLogPackage, aView,
1.137 + aCliServData, aSessionId);
1.138 + case ELogOperationViewSetFlags:
1.139 + return new(ELeave) CLogServOpViewSetFlags(aTaskInterface, aOperationManager, aMessage, aLogPackage, aView,
1.140 + aCliServData, aSessionId);
1.141 + case ELogOperationViewWindowFetch:
1.142 + return new(ELeave) CLogServOpViewWindowFetcher(aTaskInterface, aOperationManager, aMessage, aLogPackage, aView,
1.143 + aCliServData, aSessionId);
1.144 + default:
1.145 + ::PanicClientL(aMessage, ELogServFactoryUnrecognizedOperationType2);
1.146 + break;
1.147 + }
1.148 + return NULL;
1.149 + }
1.150 +
1.151 +CLogServViewBase* LogServFactory::NewViewL(TLogViewType aType,
1.152 + TLogViewId aId,
1.153 + MLogServDatabaseTransactionInterface& aDatabase,
1.154 + MLogServBackupInterface& aBackupInterface,
1.155 + CLogPackage& aPackage,
1.156 + const RMessage2& aMessage)
1.157 + {
1.158 + switch(aType)
1.159 + {
1.160 + case ELogViewTypeEvent:
1.161 + return CLogServViewEvent::NewL(aDatabase, aBackupInterface, aPackage, aId, aMessage);
1.162 + case ELogViewTypeRecent:
1.163 + return CLogServViewRecent::NewL(aDatabase, aBackupInterface, aPackage, aId, aMessage);
1.164 + case ELogViewTypeDuplicate:
1.165 + return CLogServViewDuplicate::NewL(aDatabase, aBackupInterface, aPackage, aId, aMessage);
1.166 + default:
1.167 + ::PanicClientL(aMessage, ELogServFactoryUnrecognizedViewType);
1.168 + break;
1.169 + }
1.170 + return NULL;
1.171 + }