|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Property conditions for boolean property values |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "mdeboolpropertycondition.h" |
|
19 #include "mdcserializationbuffer.h" |
|
20 #include "mdepropertydef.h" |
|
21 #include "mdcquery.h" |
|
22 |
|
23 |
|
24 /* Constructors and destructor. */ |
|
25 CMdEBoolPropertyCondition* CMdEBoolPropertyCondition::NewL( |
|
26 const CMdEPropertyDef& aPropertyDef, TBool aValue ) |
|
27 { |
|
28 CMdEBoolPropertyCondition* self = CMdEBoolPropertyCondition::NewLC( aPropertyDef, aValue ); |
|
29 CleanupStack::Pop( self ); |
|
30 return self; |
|
31 } |
|
32 |
|
33 |
|
34 CMdEBoolPropertyCondition* CMdEBoolPropertyCondition::NewLC( |
|
35 const CMdEPropertyDef& aPropertyDef, TBool aValue ) |
|
36 { |
|
37 CMdEBoolPropertyCondition* self = new ( ELeave ) CMdEBoolPropertyCondition( aPropertyDef, aValue ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CMdEBoolPropertyCondition::CMdEBoolPropertyCondition(const CMdEPropertyDef& aPropertyDef, TBool aValue) |
|
44 : CMdEPropertyCondition(EConditionTypePropertyBool, aPropertyDef), iValue(aValue) |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 void CMdEBoolPropertyCondition::ConstructL() |
|
50 { |
|
51 // Base class construction. |
|
52 CMdEPropertyCondition::ConstructL(); |
|
53 } |
|
54 |
|
55 |
|
56 CMdEBoolPropertyCondition::~CMdEBoolPropertyCondition() |
|
57 { |
|
58 } |
|
59 |
|
60 |
|
61 EXPORT_C TBool CMdEBoolPropertyCondition::Value() const |
|
62 { |
|
63 return iValue; |
|
64 } |
|
65 |
|
66 TUint32 CMdEBoolPropertyCondition::InternalQueryOptimizationFlags(TUint32& aFlags) |
|
67 { |
|
68 return CMdEPropertyCondition::InternalQueryOptimizationFlags(aFlags); |
|
69 } |
|
70 |
|
71 TUint32 CMdEBoolPropertyCondition::RequiredBufferSize() const |
|
72 { |
|
73 // Required size for property condition |
|
74 TUint32 bufferSize = sizeof( TMdCPropertyCondition ); |
|
75 |
|
76 //Required size for bool value (coverted to TUint8) |
|
77 bufferSize += CMdCSerializationBuffer::KRequiredSizeForTBool; |
|
78 |
|
79 return bufferSize; |
|
80 } |
|
81 |
|
82 void CMdEBoolPropertyCondition::SerializeL(CMdCSerializationBuffer& aBuffer, |
|
83 TMdCOffset& aFreespaceOffset) const |
|
84 { |
|
85 TMdCPropertyCondition property; |
|
86 |
|
87 property.iConditionType = iType; |
|
88 property.iNegated = iNegated; |
|
89 property.iObjectDefId = iPropertyDef.ObjectDefId(); |
|
90 property.iPropertyDefId = iPropertyDef.Id(); |
|
91 property.iCondition = aBuffer.Position() + sizeof( TMdCPropertyCondition ); |
|
92 |
|
93 property.SerializeL( aBuffer ); |
|
94 |
|
95 aBuffer.InsertL( iValue ); |
|
96 |
|
97 aFreespaceOffset = aBuffer.Position(); |
|
98 } |