|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : TransactionItemStore.cpp |
|
15 // Part of : SIPDialogs |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipStackServerDefs.h" |
|
22 #include "TransactionItemStore.h" |
|
23 #include "TransactionItem.h" |
|
24 #include "RefreshItem.h" |
|
25 #include "siprequest.h" |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CTransactionItemStore::NewL |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CTransactionItemStore* CTransactionItemStore::NewL () |
|
32 { |
|
33 CTransactionItemStore* self = CTransactionItemStore::NewLC(); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CTransactionItemStore::NewLC |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CTransactionItemStore* CTransactionItemStore::NewLC () |
|
43 { |
|
44 CTransactionItemStore* self = new(ELeave)CTransactionItemStore(); |
|
45 CleanupStack::PushL(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CTransactionItemStore::CTransactionItemStore |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CTransactionItemStore::CTransactionItemStore () |
|
54 : iList(CTransactionItemBase::Offset()) |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CTransactionItemStore::~CTransactionItemStore |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CTransactionItemStore::~CTransactionItemStore() |
|
63 { |
|
64 TSglQueIter<CTransactionItemBase> iter(iList); |
|
65 for (CTransactionItemBase* item = iter++; item; item = iter++) |
|
66 { |
|
67 iList.Remove(*item); |
|
68 delete item; |
|
69 } |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CTransactionItemStore::AddItem |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CTransactionItemStore::AddItem(CTransactionItemBase* aTransactionItem) |
|
77 { |
|
78 iList.AddLast(*aTransactionItem); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CTransactionItemStore::HasItem |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 TBool CTransactionItemStore::HasItem (TTransactionId aTransactionId) |
|
86 { |
|
87 if (!FindItem(aTransactionId)) |
|
88 { |
|
89 return EFalse; |
|
90 } |
|
91 return ETrue; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CTransactionItemStore::FindItem |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CTransactionItemBase* |
|
99 CTransactionItemStore::FindItem (TTransactionId aTransactionId) |
|
100 { |
|
101 CTransactionItemBase* foundItem = NULL; |
|
102 TSglQueIter<CTransactionItemBase> iter(iList); |
|
103 for (CTransactionItemBase* item = iter++; item && !foundItem; item = iter++) |
|
104 { |
|
105 if (item->Id() == aTransactionId) |
|
106 { |
|
107 foundItem = item; |
|
108 } |
|
109 } |
|
110 return foundItem; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CTransactionItemStore::RemoveItem |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CTransactionItemStore::RemoveItem (TTransactionId aTransactionId) |
|
118 { |
|
119 TInt err = KErrNotFound; |
|
120 CTransactionItemBase* item = FindItem(aTransactionId); |
|
121 if (item) |
|
122 { |
|
123 iList.Remove(*item); |
|
124 delete item; |
|
125 err = KErrNone; |
|
126 } |
|
127 return err; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CTransactionItemStore::OverlappingRestricted |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TBool CTransactionItemStore::OverlappingRestricted (RStringF aMethod) |
|
135 { |
|
136 TSglQueIter<CTransactionItemBase> iter(iList); |
|
137 for (CTransactionItemBase* item = iter++; item; item = iter++) |
|
138 { |
|
139 if (item->OverlappingRestricted() && item->Method() == aMethod) |
|
140 { |
|
141 return ETrue; |
|
142 } |
|
143 } |
|
144 return EFalse; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CTransactionItemStore::HasRefreshedItems |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 TBool CTransactionItemStore::HasRefreshedItems () |
|
152 { |
|
153 TBool found = EFalse; |
|
154 TSglQueIter<CTransactionItemBase> iter(iList); |
|
155 for (CTransactionItemBase* item = iter++; item && !found; item = iter++) |
|
156 { |
|
157 if(item->IsRefreshed()) |
|
158 { |
|
159 found = ETrue; |
|
160 } |
|
161 } |
|
162 return found; |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CTransactionItemStore::FindRefreshItem |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 CRefreshItem* |
|
170 CTransactionItemStore::FindRefreshItem (RStringF aMethod) |
|
171 { |
|
172 CRefreshItem* foundItem = 0; |
|
173 TSglQueIter<CTransactionItemBase> iter(iList); |
|
174 for (CTransactionItemBase* item = iter++; item && !foundItem; item = iter++) |
|
175 { |
|
176 if (item->IsRefreshed() && item->Method() == aMethod) |
|
177 { |
|
178 foundItem = static_cast<CRefreshItem*>(item); |
|
179 } |
|
180 } |
|
181 return foundItem; |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CTransactionItemStore::FindRefreshItem |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 CRefreshItem* CTransactionItemStore::FindRefreshItem (TRefreshId aRefreshId) |
|
189 { |
|
190 CRefreshItem* foundItem = 0; |
|
191 TSglQueIter<CTransactionItemBase> iter(iList); |
|
192 for (CTransactionItemBase* item = iter++; item && !foundItem; item = iter++) |
|
193 { |
|
194 if (item->IsRefreshed()) |
|
195 { |
|
196 CRefreshItem* refreshItem = static_cast<CRefreshItem*>(item); |
|
197 if (refreshItem->RefreshId() == aRefreshId) |
|
198 { |
|
199 foundItem = refreshItem; |
|
200 } |
|
201 } |
|
202 } |
|
203 return foundItem; |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CTransactionItemStore::RefreshId |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 TRefreshId CTransactionItemStore::RefreshId (TTransactionId aTransactionId) |
|
211 { |
|
212 TRefreshId id = KEmptyRefreshId; |
|
213 TSglQueIter<CTransactionItemBase> iter(iList); |
|
214 for (CTransactionItemBase* item = iter++; item && !id; item = iter++) |
|
215 { |
|
216 if (item->IsRefreshed() && item->Id() == aTransactionId) |
|
217 { |
|
218 id = static_cast<CRefreshItem*>(item)->RefreshId(); |
|
219 } |
|
220 } |
|
221 return id; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CTransactionItemStore::RefreshItemIdsL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 RArray<TRefreshId> CTransactionItemStore::RefreshItemIdsL () |
|
229 { |
|
230 TSglQueIter<CTransactionItemBase> iter(iList); |
|
231 RArray<TRefreshId> ids; |
|
232 CleanupClosePushL(ids); |
|
233 for (CTransactionItemBase* item = iter++; item; item = iter++) |
|
234 { |
|
235 if (item->IsRefreshed()) |
|
236 { |
|
237 CRefreshItem* refreshItem = static_cast<CRefreshItem*>(item); |
|
238 User::LeaveIfError(ids.Append(refreshItem->RefreshId())); |
|
239 } |
|
240 } |
|
241 CleanupStack::Pop(1); // ids |
|
242 return ids; |
|
243 } |