56
|
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 header file describes the class that handles the storage
|
|
15 |
* of triggers in RAM Structures.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#include "lbtramtriggerclientsidtree.h"
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
// ======== MEMBER FUNCTIONS ========
|
|
26 |
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
// The Symbian 2 phase constructor
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
CLbtRamTriggersClientSIDTree* CLbtRamTriggersClientSIDTree::NewL()
|
|
32 |
{
|
|
33 |
CLbtRamTriggersClientSIDTree* self = new( ELeave ) CLbtRamTriggersClientSIDTree;
|
|
34 |
CleanupStack::PushL( self );
|
|
35 |
self->ConstructL();
|
|
36 |
CleanupStack::Pop( self );
|
|
37 |
return self;
|
|
38 |
}
|
|
39 |
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// Destructor
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CLbtRamTriggersClientSIDTree::~CLbtRamTriggersClientSIDTree()
|
|
46 |
{
|
|
47 |
TRAPD(err, ResetL());
|
|
48 |
if( KErrNone != err )
|
|
49 |
{
|
|
50 |
// TODO: Log warning message that entries could not be deleted
|
|
51 |
}
|
|
52 |
delete iTriggerList;
|
|
53 |
delete iPool;
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// Add an entry to the tree
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void CLbtRamTriggersClientSIDTree::AddToTreeL(TTriggerTreeBasedOnSID* aEntry )
|
|
61 |
{
|
|
62 |
TBtreePos pos;
|
|
63 |
iTriggerList->InsertL( pos, aEntry );
|
|
64 |
}
|
|
65 |
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// Update an entry in the tree
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
|
|
72 |
void CLbtRamTriggersClientSIDTree::UpdateEntry( TSecureId aSid,CLbtContainerTriggerEntry* aEntry)
|
|
73 |
{
|
|
74 |
TBtreePos pos;
|
|
75 |
TRAP_IGNORE( iTriggerList->FindL(pos,aSid); );
|
|
76 |
TTriggerTreeBasedOnSID* tEntry=NULL;
|
|
77 |
TRAP_IGNORE( iTriggerList->ExtractAtL( pos, tEntry ) );
|
|
78 |
tEntry->trigArray.Append(aEntry);
|
|
79 |
}
|
|
80 |
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// ResetL
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CLbtRamTriggersClientSIDTree::ResetL()
|
|
87 |
{
|
|
88 |
if ( iTriggerList )
|
|
89 |
{
|
|
90 |
// Check if the TriggerList is valid. Otherwise don't execute this
|
|
91 |
// operation.
|
|
92 |
TBtreeMark index;
|
|
93 |
TBool next = iTriggerList->ResetL( index );
|
|
94 |
|
|
95 |
while( next )
|
|
96 |
{
|
|
97 |
TTriggerTreeBasedOnSID* tEntry=NULL;
|
|
98 |
iTriggerList->ExtractAtL( index, tEntry );
|
|
99 |
delete tEntry;
|
|
100 |
next = iTriggerList->NextL( index );
|
|
101 |
}
|
|
102 |
}
|
|
103 |
}
|
|
104 |
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
// IsEntryPresent
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
TBool CLbtRamTriggersClientSIDTree::IsEntryPresent(TSecureId aSid)
|
|
110 |
{
|
|
111 |
TBtreePos pos;
|
|
112 |
TBool present = EFalse;
|
|
113 |
TRAP_IGNORE( present = iTriggerList->FindL(pos,aSid) );
|
|
114 |
return present;
|
|
115 |
}
|
|
116 |
|
|
117 |
void CLbtRamTriggersClientSIDTree::SetIteratorL()
|
|
118 |
{
|
|
119 |
iNext=iTriggerList->ResetL(iMark);
|
|
120 |
}
|
|
121 |
|
|
122 |
CLbtRamTriggersClientSIDTree::TTriggerTreeBasedOnSID* CLbtRamTriggersClientSIDTree::GetNextEntryL()
|
|
123 |
{
|
|
124 |
TTriggerTreeBasedOnSID* tEntry=NULL;
|
|
125 |
if(iNext)
|
|
126 |
{
|
|
127 |
iTriggerList->ExtractAtL( iMark, tEntry );
|
|
128 |
iNext=iTriggerList->NextL( iMark );
|
|
129 |
}
|
|
130 |
return tEntry;
|
|
131 |
|
|
132 |
}
|
|
133 |
CLbtRamTriggersClientSIDTree::TTriggerTreeBasedOnSID* CLbtRamTriggersClientSIDTree::FindEntry(TSecureId aSid)
|
|
134 |
{
|
|
135 |
TBtreePos pos;
|
|
136 |
|
|
137 |
TTriggerTreeBasedOnSID* tEntry=NULL;
|
|
138 |
|
|
139 |
TBool find ;
|
|
140 |
|
|
141 |
TRAPD(err,find = iTriggerList->FindL(pos,aSid) );
|
|
142 |
if(err != KErrNone)
|
|
143 |
return NULL;
|
|
144 |
|
|
145 |
if(find)
|
|
146 |
{
|
|
147 |
TRAP(err,iTriggerList->ExtractAtL( pos, tEntry ));
|
|
148 |
if(err != KErrNone)
|
|
149 |
{
|
|
150 |
return NULL;
|
|
151 |
}
|
|
152 |
|
|
153 |
}
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
return tEntry;
|
|
158 |
|
|
159 |
}
|
|
160 |
void CLbtRamTriggersClientSIDTree::DeleteFromTreeL( TSecureId aSid )
|
|
161 |
{
|
|
162 |
|
|
163 |
|
|
164 |
iTriggerList->DeleteL(aSid);
|
|
165 |
|
|
166 |
}
|
|
167 |
|
|
168 |
void CLbtRamTriggersClientSIDTree::RemoveTriggerFromSIDTreeL( TSecureId aSid , TLbtTriggerId aId)
|
|
169 |
{
|
|
170 |
TBtreePos pos;
|
|
171 |
iTriggerList->FindL(pos,aSid);
|
|
172 |
TTriggerTreeBasedOnSID* tEntry=NULL;
|
|
173 |
iTriggerList->ExtractAtL( pos, tEntry );
|
|
174 |
for(TInt j=tEntry->trigArray.Count()-1;j>=0;j--)
|
|
175 |
{
|
|
176 |
/* Container Trigger Entry stored in the tree */
|
|
177 |
|
|
178 |
CLbtContainerTriggerEntry* contEntry=tEntry->trigArray[j];
|
|
179 |
|
|
180 |
/* Trigger Entry in Container Trigger Entry */
|
|
181 |
|
|
182 |
CLbtTriggerEntry* trigEntry=contEntry->TriggerEntry();
|
|
183 |
|
|
184 |
if(trigEntry->Id()==aId)
|
|
185 |
{
|
|
186 |
tEntry->trigArray.Remove(j);
|
|
187 |
}
|
|
188 |
|
|
189 |
}
|
|
190 |
|
|
191 |
if(tEntry->trigArray.Count() == 0)
|
|
192 |
{
|
|
193 |
DeleteFromTreeL(aSid);
|
|
194 |
}
|
|
195 |
}
|
|
196 |
// ---------------------------------------------------------------------------
|
|
197 |
// Constructor
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
CLbtRamTriggersClientSIDTree::CLbtRamTriggersClientSIDTree()
|
|
201 |
:iPool(NULL),
|
|
202 |
iTriggerList(NULL)
|
|
203 |
{
|
|
204 |
// Nothing to do now
|
|
205 |
}
|
|
206 |
|
|
207 |
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
// The 2nd phase Symbian Constructor
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CLbtRamTriggersClientSIDTree::ConstructL()
|
|
213 |
{
|
|
214 |
iTriggerList = new ( ELeave )
|
|
215 |
TBtreeFix< TTriggerTreeBasedOnSID*, TSecureId >( EBtreeFast );
|
|
216 |
iPool = CMemPagePool::NewL();
|
|
217 |
iTriggerList->Connect( iPool, &iKey );
|
|
218 |
|
|
219 |
|
|
220 |
}
|