|
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 : ResponseQueue.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipAssert.h" |
|
22 #include "sipresponse.h" |
|
23 |
|
24 #include "ResponseQueue.h" |
|
25 #include "ResponseQueueItem.h" |
|
26 |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CResponseQueue::NewL |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CResponseQueue* CResponseQueue::NewL() |
|
33 { |
|
34 return new (ELeave) CResponseQueue(); |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CResponseQueue::CResponseQueue |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CResponseQueue::CResponseQueue() |
|
42 #ifdef CPPUNIT_TEST |
|
43 //For unit tests the granularity of arrays is set to 1 to cause them to |
|
44 //allocate memory every time an item is appended to array |
|
45 : iQueue(1) |
|
46 #endif |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CResponseQueue::~CResponseQueue |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CResponseQueue::~CResponseQueue() |
|
55 { |
|
56 iQueue.ResetAndDestroy(); |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CResponseQueue::Add |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 TInt CResponseQueue::Add(CResponseQueueItem* aRespItem) |
|
64 { |
|
65 if (!aRespItem) |
|
66 { |
|
67 return KErrArgument; |
|
68 } |
|
69 |
|
70 TInt status = iQueue.Append(aRespItem); |
|
71 if (status == KErrNone) |
|
72 { |
|
73 //Ownership of the SIP response is passed to aRespItem |
|
74 aRespItem->SetResponseOwnership(ETrue); |
|
75 } |
|
76 return status; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CResponseQueue::GetNext |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CResponseQueueItem* CResponseQueue::GetNext() |
|
84 { |
|
85 if (iQueue.Count() > 0) |
|
86 { |
|
87 CResponseQueueItem* respItem = iQueue[0]; |
|
88 |
|
89 __ASSERT_DEBUG(respItem, |
|
90 User::Panic(_L("CRespQueue::GetNext() respItem = 0"), KErrNotFound)); |
|
91 |
|
92 iQueue.Remove(0); |
|
93 return respItem; |
|
94 } |
|
95 |
|
96 return NULL; |
|
97 } |