|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * Declares the CConnectionCArray |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "ConnectionCArray.h" |
|
22 #include "ConnectionInfo.h" |
|
23 #include "ConnectionDialogsLogger.h" |
|
24 #include "connectioninfosortkey.h" |
|
25 |
|
26 // CONSTANTS |
|
27 LOCAL_D const TUint KConnArrayGranularity = KConnMonMaxClientUids; |
|
28 // from rconnmon.h |
|
29 |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 |
|
33 // --------------------------------------------------------- |
|
34 // CConnectionCArray::NewL |
|
35 // --------------------------------------------------------- |
|
36 // |
|
37 CConnectionCArray* CConnectionCArray::NewL() |
|
38 { |
|
39 CLOG_ENTERFN("CConnectionCArray::NewL"); |
|
40 CConnectionCArray* self = new( ELeave ) CConnectionCArray(); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); // self |
|
44 CLOG_LEAVEFN("CConnectionCArray::NewL"); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------- |
|
51 // CConnectionCArray::CConnectionCArray |
|
52 // --------------------------------------------------------- |
|
53 // |
|
54 CConnectionCArray::CConnectionCArray() |
|
55 { |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // CConnectionCArray::ConstructL |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 void CConnectionCArray::ConstructL() |
|
64 { |
|
65 CLOG_ENTERFN("CConnectionCArray::ConstructL"); |
|
66 |
|
67 iConnArray = new( ELeave )CArrayPtrFlat<CConnectionInfo>( |
|
68 KConnArrayGranularity ); |
|
69 CLOG_LEAVEFN("CConnectionCArray::ConstructL"); |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CConnectionCArray::~CConnectionCArray |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CConnectionCArray::~CConnectionCArray() |
|
78 { |
|
79 CLOG_ENTERFN("CConnectionCArray::~CConnectionCArray"); |
|
80 |
|
81 if ( iConnArray ) |
|
82 { |
|
83 iConnArray->ResetAndDestroy(); |
|
84 } |
|
85 delete iConnArray; |
|
86 |
|
87 CLOG_LEAVEFN("CConnectionCArray::~CConnectionCArray"); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CConnectionCArray::Count |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 TInt CConnectionCArray::Count() const |
|
95 { |
|
96 return iConnArray->Count(); |
|
97 } |
|
98 |
|
99 |
|
100 // --------------------------------------------------------- |
|
101 // CConnectionCArray::AppendL |
|
102 // --------------------------------------------------------- |
|
103 // |
|
104 void CConnectionCArray::AppendL( const CConnectionInfo* aInfo ) |
|
105 { |
|
106 iConnArray->AppendL( CONST_CAST( CConnectionInfo* , aInfo ) ); |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CConnectionCArray::ResetAndDestroy |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 void CConnectionCArray::ResetAndDestroy() |
|
115 { |
|
116 iConnArray->ResetAndDestroy(); |
|
117 } |
|
118 |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // CConnectionCArray::At |
|
122 // --------------------------------------------------------- |
|
123 // |
|
124 CConnectionInfo* CConnectionCArray::At( TInt aIndex ) const |
|
125 { |
|
126 return iConnArray->At( aIndex ); |
|
127 } |
|
128 |
|
129 |
|
130 // --------------------------------------------------------- |
|
131 // CConnectionCArray::GetArrayIndex |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 TInt CConnectionCArray::GetArrayIndex( TUint aConnectionId ) const |
|
135 { |
|
136 CLOG_WRITEF( _L( "GetArrayIndex: %d" ), aConnectionId ); |
|
137 TBool found( EFalse ); |
|
138 TInt index( 0 ); |
|
139 TInt count = iConnArray->Count(); |
|
140 TUint connectionId( 0 ); |
|
141 |
|
142 while( ( index < count ) && !found ) |
|
143 { |
|
144 connectionId = ( *iConnArray )[index]->GetConnId(); |
|
145 if( connectionId == aConnectionId ) |
|
146 { |
|
147 found = ETrue; |
|
148 } |
|
149 else |
|
150 { |
|
151 ++index; |
|
152 } |
|
153 } |
|
154 |
|
155 CLOG_WRITEF( _L("Found: %d"), found ); |
|
156 |
|
157 return ( found ? index : KErrNotFound ); |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------- |
|
161 // CConnectionCArray::SortL |
|
162 // --------------------------------------------------------- |
|
163 // |
|
164 void CConnectionCArray::Sort() const |
|
165 { |
|
166 TConnectionInfoSortKey key; |
|
167 key.SetPtr( iConnArray ); |
|
168 iConnArray->Sort( key ); |
|
169 } |
|
170 |
|
171 |
|
172 // End of File |