author | ivan.fildichev@opencode.com |
Thu, 18 Nov 2010 15:42:16 +0200 | |
branch | opencode |
changeset 88 | 5e27cc612ac7 |
parent 32 | 58332560b319 |
permissions | -rw-r--r-- |
24 | 1 |
// Copyright (c) 2006-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 |
// |
|
15 |
||
16 |
||
17 |
||
18 |
//INCLUDE FILES |
|
19 |
#include "cmmlinelist.h" |
|
20 |
#include "cmmphonetsy.h" |
|
21 |
#include "cmmlinetsy.h" |
|
22 |
#include <ctsy/mmtsy_names.h> |
|
23 |
||
24 |
// ======== MEMBER FUNCTIONS ======== |
|
25 |
||
26 |
CMmLineList::CMmLineList() |
|
27 |
{ |
|
28 |
} |
|
29 |
||
30 |
CMmLineList* CMmLineList::NewL( |
|
31 |
CMmPhoneTsy* aMmPhone ) |
|
32 |
{ |
|
33 |
CMmLineList* aLineList = NULL; |
|
34 |
||
35 |
if ( aMmPhone ) |
|
36 |
{ |
|
37 |
aLineList = new ( ELeave ) CMmLineList(); |
|
38 |
CleanupStack::PushL( aLineList ); |
|
39 |
aLineList->iMmPhone = aMmPhone; |
|
40 |
aLineList->ConstructL(); |
|
41 |
CleanupStack::Pop(); |
|
42 |
} |
|
43 |
||
44 |
return aLineList; |
|
45 |
} |
|
46 |
||
47 |
void CMmLineList::ConstructL() |
|
48 |
{ |
|
49 |
//Create line container |
|
50 |
CreateContainerL(); |
|
51 |
||
52 |
//Max of 4 lines |
|
53 |
iObjectContainer->ResizeL( KMmTsyNumOfSupportedLines ); |
|
54 |
||
55 |
iInitialised = EFalse; |
|
56 |
||
57 |
CTelObject* tempObject = |
|
58 |
reinterpret_cast< CTelObject* >( this ); |
|
59 |
||
60 |
//Insert know objects to array |
|
61 |
for ( TInt i = 0; i < KMmTsyNumOfSupportedLines; i++ ) |
|
62 |
{ |
|
63 |
iObjectContainer->Delete(i); |
|
64 |
iObjectContainer->Compress(); |
|
65 |
iObjectContainer->InsertL( i, tempObject ); |
|
66 |
} |
|
67 |
||
68 |
if( KMmTsyNumOfSupportedLines < iObjectContainer->Count() ) |
|
69 |
{ |
|
70 |
//Delete array objects that are greater three |
|
71 |
//There should only be four elements in array at this point |
|
72 |
//iObjectContainer->Delete( KMmTsyNumOfSupportedLines, |
|
73 |
// iObjectContainer->Count() ); |
|
74 |
//Compress Array |
|
75 |
iObjectContainer->Compress(); |
|
76 |
} |
|
77 |
||
78 |
//no line is used |
|
79 |
for ( TInt i = 0; i < KMmTsyNumOfSupportedLines; i++) |
|
80 |
{ |
|
81 |
iIsLineInUse[ i ] = EFalse; |
|
82 |
} |
|
83 |
||
84 |
TFLOGSTRING2("TSY: CMmLineList::ConstructL:iObjectContainer->Count()=%d", iObjectContainer->Count()); |
|
85 |
||
86 |
} |
|
87 |
||
88 |
CMmLineList::~CMmLineList() |
|
89 |
{ |
|
90 |
//delete object container |
|
91 |
this->DeleteContainer(); |
|
92 |
} |
|
93 |
||
94 |
// ==================== LOCAL FUNCTIONS ===================================== |
|
95 |
||
96 |
// --------------------------------------------------------------------------- |
|
97 |
// CMmLineList::GetMmLineByMode |
|
98 |
// Returns a Ptr to a Line object by mode. |
|
99 |
//------------------------------------------------------------------------------ |
|
100 |
// |
|
101 |
CMmLineTsy* CMmLineList::GetMmLineByMode( |
|
102 |
const RMobilePhone::TMobileService aLineMode ) const |
|
103 |
{ |
|
104 |
CMmLineTsy* mmLine = NULL; |
|
105 |
||
106 |
TFLOGSTRING("TSY: CMmLineList::GetMmLineByMode"); |
|
107 |
if ( iObjectContainer && iInitialised) |
|
108 |
{ |
|
109 |
TFLOGSTRING2("TSY: CMmLineList::GetMmLineByMode::iObjectContainer->Count()=%d", iObjectContainer->Count()); |
|
32
58332560b319
Bring opencode branch up-to-date with latest cellularsrv changes
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
24
diff
changeset
|
110 |
|
24 | 111 |
for ( TInt i = 0; i < iObjectContainer->Count(); i++ ) |
112 |
{ |
|
113 |
if ( iIsLineInUse[ i ] != EFalse ) |
|
114 |
{ |
|
115 |
CMmLineTsy* mmLineSeek = |
|
116 |
reinterpret_cast<CMmLineTsy*>( |
|
117 |
iObjectContainer->At( i ) ); |
|
118 |
||
119 |
if ( mmLineSeek->LineMode() == aLineMode ) |
|
120 |
{ |
|
121 |
mmLine = mmLineSeek; |
|
122 |
break; |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
127 |
||
128 |
return mmLine; |
|
129 |
} |
|
130 |
||
131 |
// --------------------------------------------------------------------------- |
|
132 |
// CMmLineList::GetMmLineByIndex |
|
133 |
// Returns a Ptr to a Line by index. The indexing begins from 0. |
|
134 |
// --------------------------------------------------------------------------- |
|
135 |
// |
|
136 |
CMmLineTsy* CMmLineList::GetMmLineByIndex( |
|
137 |
TInt aIndex ) |
|
138 |
{ |
|
139 |
CMmLineTsy* mmLine = NULL; |
|
140 |
TFLOGSTRING("TSY: CMmLineList::GetMmLineByIndex"); |
|
141 |
//This is for checking that return objects is right |
|
142 |
CTelObject* tempObject = |
|
143 |
reinterpret_cast< CTelObject* >( this ); |
|
144 |
||
145 |
if ( iObjectContainer && iInitialised ) |
|
146 |
{ |
|
147 |
TFLOGSTRING2("TSY: CMmLineList::GetMmLineByIndex:iObjectContainer->Count()=%d", iObjectContainer->Count()); |
|
32
58332560b319
Bring opencode branch up-to-date with latest cellularsrv changes
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
24
diff
changeset
|
148 |
|
24 | 149 |
if ( aIndex >= 0 && aIndex < iObjectContainer->Count() ) |
150 |
{ |
|
151 |
if( iObjectContainer->At( aIndex ) != tempObject ) |
|
152 |
{ |
|
153 |
mmLine = reinterpret_cast<CMmLineTsy*>( |
|
154 |
iObjectContainer->At( aIndex ) ); |
|
155 |
} |
|
156 |
else |
|
157 |
{ |
|
158 |
mmLine = NULL; |
|
159 |
} |
|
160 |
||
161 |
} |
|
162 |
} |
|
163 |
||
164 |
return mmLine; |
|
165 |
} |
|
166 |
||
167 |
// --------------------------------------------------------------------------- |
|
168 |
// CMmLineList::AddLineObject |
|
169 |
// Adds a TSY to the Line list |
|
170 |
// --------------------------------------------------------------------------- |
|
171 |
// |
|
172 |
TInt CMmLineList::AddLineObject ( |
|
173 |
CTelObject* aTsyObject, const TName& aLineName ) |
|
174 |
{ |
|
175 |
TInt ret ( KErrGeneral ); |
|
176 |
||
177 |
TFLOGSTRING("TSY: CMmLineList::AddLineObject"); |
|
178 |
if ( iObjectContainer ) |
|
179 |
{ |
|
180 |
TFLOGSTRING2("TSY: CMmLineList::AddLineObject:iObjectContainer->Count()=%d", iObjectContainer->Count()); |
|
32
58332560b319
Bring opencode branch up-to-date with latest cellularsrv changes
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
24
diff
changeset
|
181 |
|
58332560b319
Bring opencode branch up-to-date with latest cellularsrv changes
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
24
diff
changeset
|
182 |
|
24 | 183 |
TInt trapError( KErrNone ); |
184 |
||
185 |
if ( 0 == aLineName.CompareF( KMmTsyVoice1LineName ) ) |
|
186 |
{ |
|
187 |
iIsLineInUse[ ELine0Voice1 ] = ETrue; |
|
188 |
iObjectContainer->Delete( ELine0Voice1 ); |
|
189 |
iObjectContainer->Compress(); |
|
190 |
TRAP( trapError, iObjectContainer->InsertL( ELine0Voice1, |
|
191 |
aTsyObject ) ); |
|
192 |
} |
|
193 |
else if ( 0 == aLineName.CompareF( KMmTsyVoice2LineName ) ) |
|
194 |
{ |
|
195 |
iIsLineInUse[ ELine1Voice2 ] = ETrue; |
|
196 |
iObjectContainer->Delete( ELine1Voice2 ); |
|
197 |
iObjectContainer->Compress(); |
|
198 |
TRAP( trapError, iObjectContainer->InsertL( ELine1Voice2, |
|
199 |
aTsyObject ) ); |
|
200 |
} |
|
201 |
else if ( 0 == aLineName.CompareF( KMmTsyDataLineName ) ) |
|
202 |
{ |
|
203 |
iIsLineInUse[ ELine2Data ] = ETrue; |
|
204 |
iObjectContainer->Delete( ELine2Data ); |
|
205 |
iObjectContainer->Compress(); |
|
206 |
TRAP( trapError, iObjectContainer->InsertL( ELine2Data, |
|
207 |
aTsyObject ) ); |
|
208 |
} |
|
209 |
else if ( 0 == aLineName.CompareF( KMmTsyFaxLineName ) ) |
|
210 |
{ |
|
211 |
iIsLineInUse[ ELine3Fax ] = ETrue; |
|
212 |
iObjectContainer->Delete( ELine3Fax ); |
|
213 |
iObjectContainer->Compress(); |
|
214 |
TRAP( trapError, iObjectContainer->InsertL( ELine3Fax, |
|
215 |
aTsyObject ) ); |
|
216 |
} |
|
217 |
//Check the trap error |
|
218 |
if ( KErrNone != trapError ) |
|
219 |
{ |
|
220 |
//change return value to indicate out of memory error |
|
221 |
ret = KErrNoMemory; |
|
222 |
} |
|
223 |
else |
|
224 |
{ |
|
225 |
//success return value |
|
226 |
ret = KErrNone; |
|
227 |
iInitialised = ETrue; |
|
228 |
} |
|
229 |
} |
|
230 |
return ret; |
|
231 |
} |
|
232 |
||
233 |
// --------------------------------------------------------------------------- |
|
234 |
// CMmLineList::RemoveObject |
|
235 |
// Marks a line object in array as not used |
|
236 |
// --------------------------------------------------------------------------- |
|
237 |
// |
|
238 |
TInt CMmLineList::RemoveLine ( |
|
239 |
const TName& aLineName ) |
|
240 |
{ |
|
241 |
TInt ret ( KErrGeneral ); |
|
242 |
||
243 |
if ( iObjectContainer ) |
|
244 |
{ |
|
245 |
ret = KErrNone; |
|
246 |
if ( 0 == aLineName.CompareF( KMmTsyVoice1LineName ) ) |
|
247 |
{ |
|
248 |
iIsLineInUse[ ELine0Voice1 ] = EFalse; |
|
249 |
} |
|
250 |
else if ( 0 == aLineName.CompareF( KMmTsyVoice2LineName ) ) |
|
251 |
{ |
|
252 |
iIsLineInUse[ ELine1Voice2 ] = EFalse; |
|
253 |
} |
|
254 |
else if ( 0 == aLineName.CompareF( KMmTsyDataLineName ) ) |
|
255 |
{ |
|
256 |
iIsLineInUse[ ELine2Data ] = EFalse; |
|
257 |
} |
|
258 |
else if ( 0 == aLineName.CompareF( KMmTsyFaxLineName ) ) |
|
259 |
{ |
|
260 |
iIsLineInUse[ ELine3Fax ] = EFalse; |
|
261 |
} |
|
262 |
else |
|
263 |
{ |
|
264 |
ret = KErrNotFound; |
|
265 |
} |
|
266 |
} |
|
267 |
return ret; |
|
268 |
} |
|
269 |
||
270 |
// --------------------------------------------------------------------------- |
|
271 |
// CMmLineList::DeleteContainer |
|
272 |
// Deletes the Line List |
|
273 |
// --------------------------------------------------------------------------- |
|
274 |
// |
|
275 |
void CMmLineList::DeleteContainer() |
|
276 |
{ |
|
277 |
if ( iObjectContainer ) |
|
278 |
{ |
|
279 |
//first reset the container |
|
280 |
iObjectContainer->Reset(); |
|
281 |
||
282 |
//then delete it |
|
283 |
delete iObjectContainer; |
|
284 |
iObjectContainer = NULL; |
|
285 |
} |
|
286 |
} |
|
287 |
||
288 |
// --------------------------------------------------------------------------- |
|
289 |
// CMmLineList::GetObjectByIndex |
|
290 |
// Returns a Ptr to a Line object by index. The indexing begins from 0. |
|
291 |
// --------------------------------------------------------------------------- |
|
292 |
// |
|
293 |
CBase* CMmLineList::GetObjectByIndex ( |
|
294 |
TInt aIndex ) const |
|
295 |
{ |
|
296 |
CBase* mmObject = NULL; |
|
297 |
||
298 |
TFLOGSTRING2("TSY: CMmLineList::GetObjectByIndex. aIndex=%d", aIndex ); |
|
299 |
if ( iObjectContainer ) |
|
300 |
{ |
|
301 |
TFLOGSTRING2("TSY: CMmLineList::GetObjectByIndex. iObjectContainer->Count()=%d", iObjectContainer->Count()); |
|
32
58332560b319
Bring opencode branch up-to-date with latest cellularsrv changes
Oscar Gonzalez <oscar.1.gonzalez@nokia.com>
parents:
24
diff
changeset
|
302 |
|
24 | 303 |
if ( iIsLineInUse[ aIndex ] ) |
304 |
{ |
|
305 |
mmObject = iObjectContainer->At( static_cast<TInt>( aIndex ) ); |
|
306 |
} |
|
307 |
} |
|
308 |
||
309 |
return mmObject; |
|
310 |
} |
|
311 |
||
312 |
// End of File |
|
313 |
||
314 |
||
315 |