|
1 /* |
|
2 * Copyright (c) 2005 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: Queue class for IMPS tid. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 #include <e32base.h> |
|
23 #include <badesca.h> |
|
24 #include "impstidqueue.h" |
|
25 |
|
26 // MACROS |
|
27 #ifndef _DEBUG |
|
28 #define _NO_IMPS_LOGGING_ |
|
29 #endif |
|
30 |
|
31 // --------------------------------------------------------- |
|
32 // CImpsTidQueue::NewL |
|
33 // --------------------------------------------------------- |
|
34 // |
|
35 CImpsTidQueue* CImpsTidQueue::NewL() |
|
36 { |
|
37 CImpsTidQueue* self = new ( ELeave ) CImpsTidQueue( 6 ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------- |
|
45 // CImpsTidQueue::ConstructL |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 void CImpsTidQueue::ConstructL() |
|
49 { |
|
50 iArray = new ( ELeave ) CDesCArrayFlat( 6 ); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CImpsTidQueue::CImpsTidQueue |
|
55 // Constructor |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CImpsTidQueue::CImpsTidQueue( TInt aCapacity ): |
|
59 iCapacity( aCapacity ), |
|
60 iNext( 0 ) |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CImpsTidQueue::~CImpsTidQueue |
|
66 // Destructor |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CImpsTidQueue::~CImpsTidQueue() |
|
70 { |
|
71 if ( iArray ) |
|
72 { |
|
73 iArray->Reset(); |
|
74 delete iArray; |
|
75 } |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CImpsTidQueue::Add |
|
80 // Adds a new orphan message to the queue |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CImpsTidQueue::Add( const TDesC& aTid ) |
|
84 { |
|
85 TInt err = KErrNone; |
|
86 iNext++; |
|
87 if ( iNext > iCapacity ) |
|
88 { |
|
89 iArray->Delete( 0 ); |
|
90 iArray->Compress(); |
|
91 } |
|
92 TRAP( err, iArray->AppendL( aTid ) ); |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CImpsTidQueue::TidFound |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TBool CImpsTidQueue::TidFound( const TDesC& aTid ) |
|
100 { |
|
101 TInt index = -1; |
|
102 TInt ret = iArray->Find( aTid, index ); |
|
103 return ret ? EFalse : ETrue; |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CImpsTidQueue::DeleteAll |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CImpsTidQueue::DeleteAll() |
|
111 { |
|
112 iNext = 0; |
|
113 iArray->Reset(); |
|
114 iArray->Compress(); |
|
115 } |
|
116 |
|
117 |
|
118 |
|
119 // End of File |