|
1 /* |
|
2 * Copyright (c) 2010 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 PosLocationServicesEnginePrivate class. |
|
15 * |
|
16 */ |
|
17 #include "poslocationservicesengineprivate.h" |
|
18 |
|
19 #include <epos_csuplsettings.h> |
|
20 #include <epos_csuplsettingparams.h> |
|
21 #include <epos_csuplsettingsconstants.h> |
|
22 |
|
23 //---------------------------------------------------------------------- |
|
24 // PosLocationServicesEnginePrivate::PosLocationServicesEnginePrivate |
|
25 //---------------------------------------------------------------------- |
|
26 PosLocationServicesEnginePrivate::PosLocationServicesEnginePrivate( |
|
27 PosLocationServiceUpdateObserver& aObserver) : |
|
28 mObserver(aObserver) |
|
29 { |
|
30 QT_TRAP_THROWING( mSuplSettings = CSuplSettings::NewL(); |
|
31 mSuplSettings->SetSessionObserverL( *this ) ); |
|
32 } |
|
33 |
|
34 //---------------------------------------------------------------------- |
|
35 // PosLocationServicesEnginePrivate::~PosLocationServicesEnginePrivate |
|
36 //---------------------------------------------------------------------- |
|
37 PosLocationServicesEnginePrivate::~PosLocationServicesEnginePrivate() |
|
38 { |
|
39 mSuplSettings->RemoveSessionObserver(); |
|
40 delete mSuplSettings; |
|
41 mSuplSettings = NULL; |
|
42 } |
|
43 |
|
44 //---------------------------------------------------------------------- |
|
45 // PosLocationServicesEnginePrivate::GetLocationServices |
|
46 //---------------------------------------------------------------------- |
|
47 int PosLocationServicesEnginePrivate::GetLocationServices(QList< |
|
48 PosLocationServiceInfo>& aLocationServiceList) |
|
49 { |
|
50 int err = 0; |
|
51 TRAP(err, GetLocationServicesL(aLocationServiceList)); |
|
52 return err; |
|
53 } |
|
54 //---------------------------------------------------------------------- |
|
55 // PosLocationServicesEnginePrivate::GetLocationServicesL |
|
56 //---------------------------------------------------------------------- |
|
57 void PosLocationServicesEnginePrivate::GetLocationServicesL(QList< |
|
58 PosLocationServiceInfo>& aLocationServiceList) |
|
59 { |
|
60 RPointerArray<CTriggerParams> triggerParams; |
|
61 CleanupClosePushL(triggerParams); |
|
62 int error = mSuplSettings->GetTriggerParams(triggerParams); |
|
63 |
|
64 int count = triggerParams.Count(); |
|
65 |
|
66 //if there are no trigger params then leave with KErrNotFound |
|
67 if (count <= 0) |
|
68 { |
|
69 User::Leave(KErrNotFound); |
|
70 } |
|
71 |
|
72 //for each entry in the paramlist populate the locationservice list |
|
73 for (int i = 0; i < count; ++i) |
|
74 { |
|
75 |
|
76 TInt64 sessionId; |
|
77 TUint64 outstandingTrigger; |
|
78 TUint64 interval; |
|
79 TTime endTime; |
|
80 TBool notificationPresent; |
|
81 TBool triggerNotificationStatus; |
|
82 CTriggerParams::TTriggerType triggerType; |
|
83 CTriggerParams::TRequestType requestType; |
|
84 HBufC* sessionName = HBufC::NewLC( |
|
85 KMaxTriggerSessionNameLen); |
|
86 |
|
87 error = triggerParams[i]->Get(sessionId, sessionName->Des(), |
|
88 notificationPresent, triggerNotificationStatus, triggerType, |
|
89 requestType, outstandingTrigger, interval); |
|
90 triggerParams[i]->GetTriggerEndTime(endTime); |
|
91 |
|
92 if (error == KErrNone) |
|
93 { |
|
94 PosLocationServiceInfo serviceInfo; |
|
95 serviceInfo.mServiceId = sessionId; |
|
96 QString sName((QChar*) (sessionName->Ptr()), |
|
97 sessionName->Length()); |
|
98 |
|
99 serviceInfo.mServiceName.append(sName); |
|
100 serviceInfo.mUpdateInterval = interval; |
|
101 serviceInfo.mEndDateTime.setDate(QDate(endTime.DateTime().Year(), |
|
102 endTime.DateTime().Month() + 1, endTime.DateTime().Day() |
|
103 + 1)); |
|
104 serviceInfo.mEndDateTime.setTime(QTime(endTime.DateTime().Hour(), |
|
105 endTime.DateTime().Minute(), endTime.DateTime().Second(), |
|
106 endTime.DateTime().MicroSecond())); |
|
107 |
|
108 aLocationServiceList.append(serviceInfo); |
|
109 } |
|
110 CleanupStack::PopAndDestroy(sessionName); |
|
111 } |
|
112 CleanupStack::Pop(&triggerParams); |
|
113 triggerParams.ResetAndDestroy(); |
|
114 |
|
115 //leave if there is an error |
|
116 User::LeaveIfError(error); |
|
117 } |
|
118 |
|
119 //---------------------------------------------------------------------- |
|
120 // PosLocationServicesEnginePrivate::RemoveLocationService |
|
121 //---------------------------------------------------------------------- |
|
122 int PosLocationServicesEnginePrivate::RemoveLocationService(int aServiceId) |
|
123 { |
|
124 return mSuplSettings->CancelTriggerSession(aServiceId); |
|
125 } |
|
126 |
|
127 //---------------------------------------------------------------------- |
|
128 // PosLocationServicesEnginePrivate::HandleSuplSessionChangeL |
|
129 //---------------------------------------------------------------------- |
|
130 void PosLocationServicesEnginePrivate::HandleSuplSessionChangeL( |
|
131 TSuplSessionEventType /*aEvent*/, TInt64 /*aSessionId*/) |
|
132 { |
|
133 mObserver.handleLocationServiceUpdate(); |
|
134 } |
|
135 |
|
136 // End of file |