|
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: This file defines the container trigger entry class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <lbttriggerdynamicinfo.h> |
|
20 #include <lbtsessiontrigger.h> |
|
21 #include <lbtstartuptrigger.h> |
|
22 #include <lbttriggerentry.h> |
|
23 #include <lbttriggerconditionbase.h> |
|
24 #include <lbttriggerconditionarea.h> |
|
25 #include <lbtgeoareabase.h> |
|
26 #include <lbtgeocircle.h> |
|
27 #include <lbtgeorect.h> |
|
28 #include <lbtgeocell.h> |
|
29 #include <lbtgeohybrid.h> |
|
30 #include "lbtcontainertriggerentry.h" |
|
31 #include "lbtcontainerextendedtriggerinfo.h" |
|
32 #include "lbtcontainerutilities.h" |
|
33 |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CLbtContainerTriggerEntry::NewL() |
|
39 // |
|
40 // (other items were commented in a header). |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CLbtContainerTriggerEntry* CLbtContainerTriggerEntry::NewL() |
|
44 { |
|
45 CLbtContainerTriggerEntry* self=new( ELeave ) CLbtContainerTriggerEntry; |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CLbtContainerTriggerEntry::NewL( |
|
55 // CLbtTriggerEntry* aEntry, |
|
56 // TLbtTriggerDynamicInfo* aDynInfo, |
|
57 // TLbtDerivedTriggerInfo* aDerivedInfo) |
|
58 // |
|
59 // (other items were commented in a header). |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 EXPORT_C CLbtContainerTriggerEntry* CLbtContainerTriggerEntry::NewL( |
|
63 CLbtTriggerEntry* aEntry, |
|
64 TLbtTriggerDynamicInfo* aDynInfo, |
|
65 CLbtExtendedTriggerInfo* aExtendedTriggerInfo) |
|
66 { |
|
67 CLbtContainerTriggerEntry* self=new( ELeave ) CLbtContainerTriggerEntry; |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL(aEntry,aDynInfo,aExtendedTriggerInfo); |
|
70 CleanupStack::Pop( self ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CLbtContainerTriggerEntry::~CLbtContainerTriggerEntry() |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C CLbtContainerTriggerEntry::~CLbtContainerTriggerEntry() |
|
80 { |
|
81 delete iExtendedTriggerInfo; |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CLbtContainerTriggerEntry::DerivedInfo() |
|
87 // |
|
88 // (other items were commented in a header). |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C CLbtExtendedTriggerInfo* CLbtContainerTriggerEntry::ExtendedTriggerInfo() |
|
92 { |
|
93 return iExtendedTriggerInfo; |
|
94 } |
|
95 |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CLbtContainerTriggerEntry::SetDerivedInfo() |
|
99 // |
|
100 // (other items were commented in a header). |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C void CLbtContainerTriggerEntry::SetExtendedTriggerInfo( |
|
104 CLbtExtendedTriggerInfo* aExtendedTriggerInfo ) |
|
105 { |
|
106 if ( iExtendedTriggerInfo ) |
|
107 { |
|
108 delete iExtendedTriggerInfo; |
|
109 } |
|
110 iExtendedTriggerInfo = aExtendedTriggerInfo; |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // Constructor |
|
115 // |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 CLbtContainerTriggerEntry::CLbtContainerTriggerEntry() : iExtendedTriggerInfo(NULL) |
|
119 { |
|
120 SetTriggerEntry(NULL); |
|
121 SetDynInfo(NULL); |
|
122 InitializeStrategyData(); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // Copy Constructor |
|
127 // |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 CLbtContainerTriggerEntry::CLbtContainerTriggerEntry( |
|
131 CLbtContainerTriggerEntry& aEntry) : iExtendedTriggerInfo(NULL) |
|
132 |
|
133 { |
|
134 SetTriggerEntry(NULL); |
|
135 SetDynInfo(NULL); |
|
136 InitializeStrategyData(); |
|
137 // ToDo : Ignoring the error as of now. Will be changed once the clone |
|
138 // methods are created in client Library. |
|
139 TRAP_IGNORE(CloneL(aEntry)); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CLbtContainerTriggerEntry::InitializeStrategyData |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CLbtContainerTriggerEntry::InitializeStrategyData() |
|
147 { |
|
148 iStrategyData.iFireTime = 0; |
|
149 iStrategyData.iActivityStatus = EActive; |
|
150 iStrategyData.iBoundaryCondition = 0; |
|
151 iStrategyData.iVisitedCell[0] = 0; |
|
152 iStrategyData.iVisitedCell[1] = 0; |
|
153 |
|
154 CLbtTriggerEntry* triggerEntry = TriggerEntry(); |
|
155 if( triggerEntry ) |
|
156 { |
|
157 // Initialise hybrid data |
|
158 iStrategyData.iHybridState = EHybridNone; |
|
159 |
|
160 if( triggerEntry->GetCondition() ) |
|
161 { |
|
162 if( triggerEntry->GetCondition()->Type() == CLbtTriggerConditionBase::ETriggerConditionArea ) |
|
163 { |
|
164 // Get the condition area base |
|
165 CLbtTriggerConditionArea* conditionArea = |
|
166 static_cast<CLbtTriggerConditionArea*>(triggerEntry->GetCondition()); |
|
167 |
|
168 if( conditionArea->TriggerArea() ) |
|
169 { |
|
170 // Check if the area is a circle |
|
171 if(conditionArea->TriggerArea()->Type() == CLbtGeoAreaBase::ECircle) |
|
172 { |
|
173 CLbtGeoCircle* circle = static_cast<CLbtGeoCircle*>(conditionArea->TriggerArea()); |
|
174 RPointerArray<CLbtGeoAreaBase> additionalArea = circle->GetAdditionalGeoAreaInfo(); |
|
175 if( additionalArea.Count() ) |
|
176 { |
|
177 iStrategyData.iHybridState = EHybridInActive; |
|
178 } |
|
179 } |
|
180 } |
|
181 } |
|
182 } |
|
183 } |
|
184 } |
|
185 |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // Clone method |
|
189 // |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CLbtContainerTriggerEntry::CloneL(CLbtContainerTriggerEntry& aEntry) |
|
193 { |
|
194 CLbtTriggerEntry::TType trigType; |
|
195 trigType=aEntry.TriggerEntry()->Type(); |
|
196 CLbtTriggerEntry* trigEntry=aEntry.TriggerEntry(); |
|
197 CLbtTriggerConditionBase* trigCondition= trigEntry->GetCondition(); |
|
198 TLbtTriggerDynamicInfo* dynInfo=aEntry.DynInfo(); |
|
199 CLbtExtendedTriggerInfo* extInfo=aEntry.ExtendedTriggerInfo(); |
|
200 CLbtTriggerEntry* entry=NULL; |
|
201 |
|
202 if(trigType==CLbtTriggerEntry::ETypeSession) |
|
203 { |
|
204 entry=CLbtSessionTrigger::NewL(); |
|
205 entry->SetId(trigEntry->Id()); |
|
206 entry->SetNameL(trigEntry->Name()); |
|
207 entry->SetManagerUi(trigEntry->ManagerUi()); |
|
208 entry->SetState(trigEntry->State()); |
|
209 entry->SetTimeToRearm( trigEntry->TimeToRearm() ); |
|
210 if(trigCondition->Type() == |
|
211 CLbtTriggerConditionBase::ETriggerConditionArea) |
|
212 { |
|
213 CLbtTriggerConditionArea* cond = |
|
214 (CLbtTriggerConditionArea*)trigCondition; |
|
215 CLbtTriggerConditionArea* trigCondArea = |
|
216 CLbtTriggerConditionArea::NewL(); |
|
217 |
|
218 CLbtGeoAreaBase* trigArea = NULL; |
|
219 trigCondArea->SetDirection(cond->Direction()); |
|
220 CLbtGeoAreaBase* areaBase=cond->TriggerArea(); |
|
221 |
|
222 trigArea = LbtContainerUtilities::CopyGeoAreaL( areaBase ); |
|
223 trigCondArea->SetTriggerArea(trigArea); |
|
224 entry->SetCondition(trigCondArea); |
|
225 SetTriggerEntry(entry); |
|
226 } |
|
227 |
|
228 } |
|
229 else |
|
230 { |
|
231 entry=CLbtStartupTrigger::NewL(); |
|
232 } |
|
233 |
|
234 if(dynInfo!=NULL) |
|
235 { |
|
236 TLbtTriggerDynamicInfo* dynInfoPtr=new TLbtTriggerDynamicInfo; |
|
237 dynInfoPtr->iValidity=dynInfo->iValidity; |
|
238 dynInfoPtr->iDistanceToLatestLocation=dynInfo->iDistanceToLatestLocation; |
|
239 SetDynInfo(dynInfoPtr); |
|
240 } |
|
241 |
|
242 if(extInfo!=NULL) |
|
243 { |
|
244 iExtendedTriggerInfo = CLbtExtendedTriggerInfo::NewL(); |
|
245 iExtendedTriggerInfo->SetTriggerRectangleArea(extInfo->TriggerReactangleArea()) ; |
|
246 iExtendedTriggerInfo->SetHysteresisRadius(extInfo->HysteresisRadius()); |
|
247 iExtendedTriggerInfo->SetTriggerFiredState(extInfo->IsTriggerFired()); |
|
248 iExtendedTriggerInfo->SetOwnerSid(extInfo->OwnerSid()); |
|
249 iExtendedTriggerInfo->SetTriggerFireOnCreation(extInfo->IsTriggerFireOnCreation()); |
|
250 } |
|
251 } |
|
252 // --------------------------------------------------------------------------- |
|
253 // Symbian 2nd phase of Construction |
|
254 // |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CLbtContainerTriggerEntry::ConstructL() |
|
258 { |
|
259 ConstructL(NULL,NULL,NULL); |
|
260 } |
|
261 |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // Symbian 2nd phase of Construction |
|
265 // |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CLbtContainerTriggerEntry::ConstructL( CLbtTriggerEntry* aEntry, |
|
269 TLbtTriggerDynamicInfo* aDynInfo, |
|
270 CLbtExtendedTriggerInfo* aExtendedTriggerInfo ) |
|
271 { |
|
272 SetTriggerEntry(aEntry); |
|
273 SetDynInfo(aDynInfo); |
|
274 iExtendedTriggerInfo = aExtendedTriggerInfo; |
|
275 |
|
276 // Initialize to default values |
|
277 iStrategyData.iActivityStatus = EActive; |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // CLbtContainerTriggerEntry::SetStrategyData |
|
282 // --------------------------------------------------------------------------- |
|
283 // |
|
284 EXPORT_C void CLbtContainerTriggerEntry::SetStrategyData( TStrategyData& aStartegyData ) |
|
285 { |
|
286 iStrategyData = aStartegyData; |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // CLbtContainerTriggerEntry::StrategyData |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 EXPORT_C TStrategyData CLbtContainerTriggerEntry::StrategyData() |
|
294 { |
|
295 return iStrategyData; |
|
296 } |
|
297 // end of file |
|
298 |