|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qmlbackendmonitorao_s60_p.h" |
|
43 #include "qgeoareamonitor_s60_p.h" |
|
44 #include "qmlbackendmonitorinfo_s60_p.h" |
|
45 |
|
46 #include <lbtsessiontrigger.h> |
|
47 #include <lbtgeocircle.h> |
|
48 #include <lbttriggerconditionarea.h> |
|
49 #include <lbttriggerentry.h> |
|
50 |
|
51 QTM_BEGIN_NAMESPACE |
|
52 |
|
53 |
|
54 //static member of the QMLBackendMonitorAO object holding the address of the object |
|
55 QMLBackendMonitorAO* QMLBackendMonitorAO::iBackendMonitorAO = NULL; |
|
56 |
|
57 //static member of the QMLBackendMonitorAO object maintaining the reference count |
|
58 TInt QMLBackendMonitorAO::refCount = 0; |
|
59 |
|
60 //request for notification of the trigger fired events |
|
61 void QMLBackendMonitorAO::NotifyFiredEvent() |
|
62 { |
|
63 if (!IsActive()) { |
|
64 iLbt.NotifyTriggerFired(iTriggerInfo, iStatus); |
|
65 SetActive(); |
|
66 } |
|
67 } |
|
68 |
|
69 //static function called prior to the destruction of the |
|
70 //singleton QMLBackendMonitorAO object |
|
71 void QMLBackendMonitorAO::DeleteAO(QGeoAreaMonitorS60* aParent) |
|
72 { |
|
73 //decrement the reference count |
|
74 refCount--; |
|
75 if (refCount == 0) { |
|
76 delete iBackendMonitorAO; |
|
77 iBackendMonitorAO = NULL; |
|
78 } |
|
79 } |
|
80 |
|
81 QMLBackendMonitorAO::~QMLBackendMonitorAO() |
|
82 { |
|
83 Cancel(); |
|
84 delete iTriggerMonitorInfo; //deletes the CBackendMonitorInfo object holding the linked list |
|
85 iLbt.Close(); //closes the subsession |
|
86 } |
|
87 |
|
88 |
|
89 void QMLBackendMonitorAO::DoCancel() |
|
90 { |
|
91 if (IsActive()) { //if request is still active,cancel the CancelNotifyTriggerFired request |
|
92 iLbt.CancelNotifyTriggerFired(); |
|
93 } |
|
94 } |
|
95 |
|
96 void QMLBackendMonitorAO::RunL() |
|
97 { |
|
98 CMonitorTriggerInfo *triggerInfo = NULL; |
|
99 switch (iStatus.Int()) { |
|
100 case KErrNone : |
|
101 //retrieve the triggerInfo corresponding to iTriggerInfo.iTriggerId |
|
102 triggerInfo = iTriggerMonitorInfo->getMonitorTriggerInfo( |
|
103 iTriggerInfo.iTriggerId); |
|
104 if (triggerInfo) { |
|
105 //callback called only if generated for the current AO - Trigger ID |
|
106 (triggerInfo->iParent)->handleTriggerEvent(iTriggerInfo.iFiredPositionInfo , |
|
107 triggerInfo->iType); |
|
108 } |
|
109 break; |
|
110 default : |
|
111 break; |
|
112 } |
|
113 |
|
114 //request for any trigger fired event, for any triggers owned by the client |
|
115 NotifyFiredEvent(); |
|
116 } |
|
117 |
|
118 QMLBackendMonitorAO* QMLBackendMonitorAO::NewL(RLbtServer &aLbt) |
|
119 { |
|
120 //increment the reference count |
|
121 refCount++; |
|
122 if (!iBackendMonitorAO) { |
|
123 iBackendMonitorAO = QMLBackendMonitorAO::NewLC(aLbt); |
|
124 CleanupStack::Pop(); |
|
125 } |
|
126 return iBackendMonitorAO; |
|
127 } |
|
128 |
|
129 QMLBackendMonitorAO* QMLBackendMonitorAO::NewLC(RLbtServer &aLbtServer) |
|
130 { |
|
131 QMLBackendMonitorAO *self = new(ELeave) QMLBackendMonitorAO; |
|
132 CleanupStack::PushL(self); |
|
133 self->ConstructL(aLbtServer); |
|
134 if (!self->isValid()) { |
|
135 delete self; |
|
136 self = NULL; |
|
137 } |
|
138 return self; |
|
139 } |
|
140 |
|
141 void QMLBackendMonitorAO::ConstructL(RLbtServer &aLbtServ) |
|
142 { |
|
143 if (iLbt.Open(aLbtServ) == KErrNone) { //opens the subsession |
|
144 subsessionCreated = TRUE; |
|
145 iTriggerMonitorInfo = CBackendMonitorInfo::NewL(); |
|
146 } |
|
147 } |
|
148 |
|
149 QMLBackendMonitorAO::QMLBackendMonitorAO() |
|
150 : CActive(EPriorityStandard), // Standard priority |
|
151 subsessionCreated(FALSE) |
|
152 { |
|
153 CActiveScheduler::Add(this); |
|
154 } |
|
155 |
|
156 QTM_END_NAMESPACE |
|
157 |