|
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: Implementation of class representing session trigger |
|
15 * entries. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <s32strm.h> |
|
21 #include "lbtsessiontrigger.h" |
|
22 #include "lbttriggerentry.h" |
|
23 #include "lbttriggerconditionbase.h" |
|
24 #include "lbttriggerconditionarea.h" |
|
25 |
|
26 const TInt EnabledState=1; |
|
27 const TInt DisabledState=2; |
|
28 const TInt ConditionArea=1; |
|
29 // ======== LOCAL FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CLbtSessionTrigger::NewL() |
|
33 // |
|
34 // (other items were commented in a header). |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 EXPORT_C CLbtSessionTrigger* CLbtSessionTrigger::NewL() |
|
38 { |
|
39 CLbtSessionTrigger* self = new( ELeave ) CLbtSessionTrigger; |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CLbtSessionTrigger::NewL() |
|
49 // |
|
50 // (other items were commented in a header). |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CLbtSessionTrigger* CLbtSessionTrigger::NewLC() |
|
54 { |
|
55 CLbtSessionTrigger* self = new( ELeave ) CLbtSessionTrigger; |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 // --------------------------------------------------------------------------- |
|
61 // CLbtSessionTrigger::NewL(TCoordinate aCenter, |
|
62 // TReal aRadius) |
|
63 // (other items were commented in a header). |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 EXPORT_C CLbtSessionTrigger* CLbtSessionTrigger::NewL( |
|
67 const TDesC& aName, |
|
68 TLbtTriggerState aState, |
|
69 CRequestor::TRequestorType aRequestorType, |
|
70 CRequestor::TRequestorFormat aRequestorFormat, |
|
71 const TDesC& aRequestorData, |
|
72 TUid aManagerUi, |
|
73 CLbtTriggerConditionBase* aCondition) |
|
74 { |
|
75 CLbtSessionTrigger* self = new( ELeave ) CLbtSessionTrigger; |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL(aName,aState,aRequestorType,aRequestorFormat,aRequestorData,aManagerUi,aCondition); |
|
78 CleanupStack::Pop( self ); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CLbtSessionTrigger::NewL() |
|
84 // |
|
85 // (other items were commented in a header). |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C CLbtSessionTrigger* CLbtSessionTrigger::NewL( |
|
89 const TDesC& aName, |
|
90 CLbtTriggerEntry::TLbtTriggerState aState, |
|
91 const RRequestorStack& aRequestors, |
|
92 TUid aManagerUi, |
|
93 CLbtTriggerConditionBase* aCondition ) |
|
94 |
|
95 { |
|
96 CLbtSessionTrigger* self = new( ELeave ) CLbtSessionTrigger; |
|
97 CleanupStack::PushL( self ); |
|
98 self->ConstructL(aName,aState, aRequestors, aManagerUi, aCondition); |
|
99 CleanupStack::Pop( self ); |
|
100 return self; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CLbtSessionTrigger::Type() |
|
105 // |
|
106 // (other items were commented in a header). |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C CLbtTriggerEntry::TType CLbtSessionTrigger::Type() const |
|
110 { |
|
111 return CLbtTriggerEntry::ETypeSession; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CLbtSessionTrigger::CLbtSessionTrigger() |
|
116 // Default constructor |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 CLbtSessionTrigger::CLbtSessionTrigger() |
|
120 { |
|
121 |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CLbtSessionTrigger::~CLbtSessionTrigger() |
|
126 // Destructor |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 CLbtSessionTrigger::~CLbtSessionTrigger() |
|
130 { |
|
131 |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CLbtSessionTrigger::ConstructL() |
|
136 // Symbian 2nd phase constructor can leave. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CLbtSessionTrigger::ConstructL(const TDesC& aName,TLbtTriggerState aState, |
|
140 CRequestor::TRequestorType aRequestorType, |
|
141 CRequestor::TRequestorFormat aRequestorFormat, |
|
142 const TDesC& aRequestorData, |
|
143 TUid aManagerUi, |
|
144 CLbtTriggerConditionBase* aCondition) |
|
145 { |
|
146 SetNameL(aName); |
|
147 SetState(aState); |
|
148 SetRequestorL(aRequestorType,aRequestorFormat,aRequestorData); |
|
149 SetCondition(aCondition); |
|
150 SetManagerUi(aManagerUi); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // CLbtSessionTrigger::ConstructL() |
|
155 // Symbian 2nd phase constructor can leave. |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CLbtSessionTrigger::ConstructL(const TDesC& aName, |
|
159 CLbtTriggerEntry::TLbtTriggerState aState, |
|
160 const RRequestorStack& aRequestors, |
|
161 TUid aManagerUi, |
|
162 CLbtTriggerConditionBase* aCondition) |
|
163 |
|
164 { |
|
165 SetNameL(aName); |
|
166 SetState(aState); |
|
167 SetManagerUi(aManagerUi); |
|
168 SetCondition(aCondition); |
|
169 SetRequestorsL(aRequestors); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CLbtSessionTrigger::DoInternalizeL() |
|
174 // (other items were commented in a header). |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CLbtSessionTrigger::DoInternalizeL(RReadStream& aStream) |
|
178 { |
|
179 SetId(aStream.ReadInt32L()); |
|
180 TBuf16<KLbtMaxNameLength> name; |
|
181 TInt namLength=aStream.ReadInt32L(); |
|
182 aStream.ReadL(name,namLength); |
|
183 SetNameL(name); |
|
184 TInt state; |
|
185 state=aStream.ReadInt8L(); |
|
186 TLbtTriggerState trigState=CLbtTriggerEntry::EStateEnabled; |
|
187 if(state==EnabledState) |
|
188 trigState=CLbtTriggerEntry::EStateEnabled; |
|
189 else if(state==DisabledState) |
|
190 trigState=CLbtTriggerEntry::EStateDisabled; |
|
191 SetState(trigState); |
|
192 TInt rearmTime = aStream.ReadInt32L(); |
|
193 SetTimeToRearm( rearmTime ); |
|
194 TUid managerUid; |
|
195 managerUid.iUid=aStream.ReadInt32L(); |
|
196 SetManagerUi(managerUid); |
|
197 TInt condType=aStream.ReadInt8L(); |
|
198 if(condType==ConditionArea) |
|
199 { |
|
200 CLbtTriggerConditionArea *area=CLbtTriggerConditionArea::NewL(); |
|
201 area->InternalizeL(aStream); |
|
202 SetCondition(area); |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // CLbtSessionTrigger::DoExternalizeL() |
|
208 // (other items were commented in a header). |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 void CLbtSessionTrigger::DoExternalizeL(RWriteStream& aStream) const |
|
212 { |
|
213 aStream.WriteInt32L(Id()); |
|
214 const TDesC& name=Name(); |
|
215 TInt len=name.Length(); |
|
216 aStream.WriteInt32L(len); |
|
217 aStream.WriteL(name,len); |
|
218 TLbtTriggerState state=State(); |
|
219 |
|
220 if(state==CLbtTriggerEntry::EStateEnabled) |
|
221 aStream.WriteInt8L(EnabledState); |
|
222 else |
|
223 aStream.WriteInt8L(DisabledState); |
|
224 TInt rearmTime = TimeToRearm(); |
|
225 aStream.WriteInt32L( rearmTime ); |
|
226 aStream.WriteInt32L(ManagerUi().iUid); |
|
227 const CLbtTriggerConditionBase* Cond=GetCondition(); |
|
228 CLbtTriggerConditionBase::TType condType; |
|
229 if(Cond!=NULL) |
|
230 { |
|
231 condType=Cond->Type(); |
|
232 if(condType==CLbtTriggerConditionBase::ETriggerConditionArea) |
|
233 aStream.WriteInt8L(ConditionArea); |
|
234 Cond->ExternalizeL(aStream); |
|
235 } |
|
236 else |
|
237 { |
|
238 aStream.WriteInt8L(0); |
|
239 } |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // CLbtSessionTrigger::ConstructL() |
|
244 // Symbian 2nd phase constructor can leave. |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 void CLbtSessionTrigger::ConstructL() |
|
248 { |
|
249 SetState(CLbtTriggerEntry::EStateEnabled); |
|
250 SetId(KLbtNullTriggerId); |
|
251 SetCondition(NULL); |
|
252 SetNameL(KNullDesC()); |
|
253 } |
|
254 |