|
1 /* |
|
2 * Copyright (c) 2006 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: class containing extended information about a trigger |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lbtcontainerextendedtriggerinfo.h" |
|
20 |
|
21 // ======== MEMBER FUNCTIONS ======== |
|
22 |
|
23 // --------------------------------------------------------------------------- |
|
24 // CLbtExtendedTriggerInfo::NewL() |
|
25 // |
|
26 // (other items were commented in a header). |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 EXPORT_C CLbtExtendedTriggerInfo* CLbtExtendedTriggerInfo::NewL() |
|
30 { |
|
31 CLbtExtendedTriggerInfo* self=new( ELeave ) CLbtExtendedTriggerInfo; |
|
32 CleanupStack::PushL( self ); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop( self ); |
|
35 return self; |
|
36 } |
|
37 |
|
38 EXPORT_C CLbtExtendedTriggerInfo* CLbtExtendedTriggerInfo::NewL( |
|
39 TLbtTriggerRectArea aArea, |
|
40 TReal aHystRadius, |
|
41 TBool aFired, |
|
42 const TDesC8& aStrategyData, |
|
43 TSecureId aOwnerSid, |
|
44 TBool aFireOnCreation) |
|
45 { |
|
46 CLbtExtendedTriggerInfo* self=new( ELeave ) CLbtExtendedTriggerInfo; |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL( aArea, |
|
49 aHystRadius, |
|
50 aFired, |
|
51 aStrategyData, |
|
52 aOwnerSid, |
|
53 aFireOnCreation ); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 EXPORT_C CLbtExtendedTriggerInfo::~CLbtExtendedTriggerInfo() |
|
59 { |
|
60 delete iStrategyData; |
|
61 } |
|
62 |
|
63 EXPORT_C const CLbtExtendedTriggerInfo::TLbtTriggerRectArea |
|
64 CLbtExtendedTriggerInfo::TriggerReactangleArea() const |
|
65 { |
|
66 return iArea; |
|
67 } |
|
68 |
|
69 EXPORT_C void CLbtExtendedTriggerInfo::SetTriggerRectangleArea( |
|
70 const CLbtExtendedTriggerInfo::TLbtTriggerRectArea& aArea) |
|
71 { |
|
72 iArea = aArea; |
|
73 } |
|
74 |
|
75 EXPORT_C const TReal& CLbtExtendedTriggerInfo::HysteresisRadius() const |
|
76 { |
|
77 return iHystRadius; |
|
78 } |
|
79 |
|
80 EXPORT_C void CLbtExtendedTriggerInfo::SetHysteresisRadius( |
|
81 const TReal& aHystRadius) |
|
82 { |
|
83 iHystRadius = aHystRadius; |
|
84 } |
|
85 |
|
86 EXPORT_C TBool CLbtExtendedTriggerInfo::IsTriggerFired() const |
|
87 { |
|
88 return iFired; |
|
89 } |
|
90 |
|
91 EXPORT_C void CLbtExtendedTriggerInfo::SetTriggerFiredState(TBool aFired) |
|
92 { |
|
93 iFired = aFired; |
|
94 } |
|
95 |
|
96 EXPORT_C const TDesC8& CLbtExtendedTriggerInfo::StategyData() const |
|
97 { |
|
98 return *iStrategyData; |
|
99 } |
|
100 |
|
101 EXPORT_C TLbtTriggerFireInfo CLbtExtendedTriggerInfo::GetFiredInfo() const |
|
102 { |
|
103 return iFiredInfo; |
|
104 } |
|
105 |
|
106 EXPORT_C void CLbtExtendedTriggerInfo::SetFiredInfo(TLbtTriggerFireInfo aFiredInfo) |
|
107 { |
|
108 iFiredInfo = aFiredInfo; |
|
109 } |
|
110 |
|
111 EXPORT_C void CLbtExtendedTriggerInfo::SetStrategyDataL( |
|
112 const TDesC8& aStrategyData) |
|
113 { |
|
114 // Pre-allocate the memory. If the memory allocation fails atleast the |
|
115 // old data is still valid in this case. |
|
116 HBufC8 *tmp = HBufC8::NewL( aStrategyData.Length() ); |
|
117 tmp->Des().Copy( aStrategyData ); |
|
118 if ( iStrategyData ) |
|
119 { |
|
120 delete iStrategyData; |
|
121 iStrategyData = NULL; |
|
122 } |
|
123 iStrategyData = tmp; |
|
124 } |
|
125 |
|
126 EXPORT_C const TSecureId& CLbtExtendedTriggerInfo::OwnerSid() const |
|
127 { |
|
128 return iOwnerSid; |
|
129 } |
|
130 |
|
131 EXPORT_C void CLbtExtendedTriggerInfo::SetOwnerSid(const TSecureId& aOwnerSid) |
|
132 { |
|
133 iOwnerSid = aOwnerSid; |
|
134 } |
|
135 |
|
136 EXPORT_C TBool CLbtExtendedTriggerInfo::IsTriggerFireOnCreation() const |
|
137 { |
|
138 return iFireOnCreation; |
|
139 } |
|
140 |
|
141 EXPORT_C void CLbtExtendedTriggerInfo::SetTriggerFireOnCreation(TBool aFireOnCreation) |
|
142 { |
|
143 iFireOnCreation = aFireOnCreation; |
|
144 } |
|
145 |
|
146 CLbtExtendedTriggerInfo::CLbtExtendedTriggerInfo() |
|
147 { |
|
148 } |
|
149 |
|
150 void CLbtExtendedTriggerInfo::ConstructL() |
|
151 { |
|
152 // Fill iStrategyData with KNullDesC. |
|
153 // This is required because the method StategyData() |
|
154 // does not return a pointer. Instead it returns a TDesC&. |
|
155 // If this HBufC is null then accessing the Ptr will result |
|
156 // in a KERN-EXEC 3. |
|
157 SetStrategyDataL( KNullDesC8() ); |
|
158 } |
|
159 |
|
160 void CLbtExtendedTriggerInfo::ConstructL( |
|
161 TLbtTriggerRectArea aArea, |
|
162 TReal aHystRadius, |
|
163 TBool aFired, |
|
164 const TDesC8& aStrategyData, |
|
165 TSecureId aOwnerSid, |
|
166 TBool aFireOnCreation) |
|
167 { |
|
168 SetTriggerRectangleArea( aArea ); |
|
169 SetHysteresisRadius( aHystRadius ); |
|
170 SetTriggerFiredState( aFired ); |
|
171 SetStrategyDataL( aStrategyData ); |
|
172 SetOwnerSid( aOwnerSid ); |
|
173 SetTriggerFireOnCreation(aFireOnCreation); |
|
174 } |
|
175 |