|
1 // Copyright (c) 2004-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 : CRequestQueue.cpp |
|
15 // Part of : ServerResolver |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "CRequestQueue.h" |
|
22 #include "CServerQuery.h" |
|
23 #include "MSIPServerResolverObserver.h" |
|
24 |
|
25 // ---------------------------------------------------------------------------- |
|
26 // CRequestQueue::CRequestQueue |
|
27 // ---------------------------------------------------------------------------- |
|
28 // |
|
29 CRequestQueue::CRequestQueue(): iList( CServerQuery::iOffset ), |
|
30 iListIter( iList ) |
|
31 {} |
|
32 |
|
33 // ---------------------------------------------------------------------------- |
|
34 // CRequestQueue::NewL |
|
35 // ---------------------------------------------------------------------------- |
|
36 // |
|
37 CRequestQueue* CRequestQueue::NewL() |
|
38 { |
|
39 CRequestQueue* self = NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // CRequestQueue::NewLC |
|
46 // ---------------------------------------------------------------------------- |
|
47 // |
|
48 CRequestQueue* CRequestQueue::NewLC() |
|
49 { |
|
50 CRequestQueue* self = new ( ELeave ) CRequestQueue(); |
|
51 CleanupStack::PushL( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CRequestQueue::~CRequestQueue |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 CRequestQueue::~CRequestQueue() |
|
60 { |
|
61 CServerQuery* query; |
|
62 iListIter.SetToFirst(); |
|
63 query = iListIter++; |
|
64 while ( query ) |
|
65 { |
|
66 iList.Remove( *query ); |
|
67 delete query; |
|
68 query = iListIter++; |
|
69 } |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // CRequestQueue::CancelQuery |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 void CRequestQueue::CancelQuery( MSIPServerResolverObserver* aObserver ) |
|
77 { |
|
78 if ( !iList.IsEmpty() ) |
|
79 { |
|
80 CServerQuery* query; |
|
81 iListIter.SetToFirst(); |
|
82 query = iListIter++; |
|
83 while( query ) |
|
84 { |
|
85 if( query->ServerResolverObserver() == aObserver ) |
|
86 { |
|
87 iList.Remove( *query ); |
|
88 delete query; |
|
89 } |
|
90 query = iListIter++; |
|
91 } |
|
92 } |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CRequestQueue::AddL |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 void CRequestQueue::AddL( CServerQuery& aQuery ) |
|
100 { |
|
101 if ( !iList.IsEmpty() ) |
|
102 { |
|
103 CServerQuery* query; |
|
104 iListIter.SetToFirst(); |
|
105 query = iListIter++; |
|
106 while ( query ) |
|
107 { |
|
108 if ( query->ServerResolverObserver() == |
|
109 aQuery.ServerResolverObserver() ) |
|
110 { |
|
111 User::Leave( KErrAlreadyExists ); |
|
112 } |
|
113 query = iListIter++; |
|
114 } |
|
115 } |
|
116 iList.AddLast( aQuery ); |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CRequestQueue::NextQuery |
|
121 // ---------------------------------------------------------------------------- |
|
122 // |
|
123 CServerQuery* CRequestQueue::NextQuery() |
|
124 { |
|
125 if ( !iList.IsEmpty() ) |
|
126 { |
|
127 CServerQuery* query = iList.First(); |
|
128 iList.Remove( *query ); |
|
129 return query; |
|
130 } |
|
131 return 0; |
|
132 } |
|
133 |