|
1 /* |
|
2 * Copyright (c) 2003 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: Array wrapper for server list |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CWVSettingsUIServersArray.h" |
|
21 #include "WVSettingsUIPanics.h" |
|
22 #include "CWVSettingsUIDefs.h" |
|
23 #include <cimpssapsettingslist.h> |
|
24 // CONSTANTS |
|
25 |
|
26 |
|
27 // ================= MEMBER FUNCTIONS ======================= |
|
28 |
|
29 // Two-phased constructor. |
|
30 CWVSettingsUIServersArray* CWVSettingsUIServersArray::NewL( MDesCArray& aServerList, |
|
31 RArray<TInt>& aProtectedServers ) |
|
32 { |
|
33 CWVSettingsUIServersArray* self = new ( ELeave ) CWVSettingsUIServersArray( |
|
34 aServerList, |
|
35 aProtectedServers ); |
|
36 |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop( self ); |
|
40 |
|
41 return self; |
|
42 } |
|
43 |
|
44 // Destructor |
|
45 CWVSettingsUIServersArray::~CWVSettingsUIServersArray() |
|
46 { |
|
47 delete iData; |
|
48 delete iServerList; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // CWVSettingsUIServersArray::MdcaCount |
|
53 // Returns the number of descriptor elements in a descriptor array. |
|
54 // (other items were commented in a header). |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 TInt CWVSettingsUIServersArray::MdcaCount() const |
|
58 { |
|
59 return iServerList->MdcaCount(); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // CWVSettingsUIServersArray::MdcaCount |
|
64 // Return pointer to descriptor data in given index of an array |
|
65 // (other items were commented in a header). |
|
66 // --------------------------------------------------------- |
|
67 // |
|
68 TPtrC16 CWVSettingsUIServersArray::MdcaPoint( TInt aIndex ) const |
|
69 { |
|
70 __ASSERT_ALWAYS( aIndex >= 0 && aIndex < iServerList->MdcaCount(), |
|
71 User::Panic( KPanicText, EServersArrayIndexOutOfBounds ) ); |
|
72 |
|
73 // Copy server's name to buffer |
|
74 // Altough this is const method, next line does affect it's member data, |
|
75 // because of performance -> no need to create new buffer every time... |
|
76 *iData = iServerList->MdcaPoint( aIndex ).Left( KWVSettingsServerNameMaxLength ); |
|
77 |
|
78 // Add needed format string |
|
79 TPtr dataPtr( iData->Des() ); |
|
80 |
|
81 dataPtr.Insert( 0, KServerNameFormatTrailer ); |
|
82 |
|
83 if ( ( static_cast<CIMPSSAPSettingsList*> |
|
84 ( iServerList ) )->At( aIndex )->Protection() == ESAPBrandProtection ) |
|
85 { |
|
86 dataPtr.Append( KFirstIconFormat ); |
|
87 } |
|
88 |
|
89 return *iData; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CWVSettingsUIServersArray::RawDataMdcaPoint |
|
94 // |
|
95 // (other items were commented in a header). |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 TPtrC16 CWVSettingsUIServersArray::RawDataMdcaPoint( TInt aIndex ) const |
|
99 { |
|
100 return iServerList->MdcaPoint( aIndex ); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------- |
|
104 // CWVSettingsUIServersArray::ReplaceModelL |
|
105 // |
|
106 // (other items were commented in a header). |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 void CWVSettingsUIServersArray::ReplaceModelL( MDesCArray* aServerList ) |
|
110 { |
|
111 if ( !aServerList ) |
|
112 { |
|
113 User::Leave( EServersArrayReplacelingModelWithNULL ); |
|
114 } |
|
115 |
|
116 delete iServerList; |
|
117 iServerList = aServerList; |
|
118 } |
|
119 |
|
120 // C++ default constructor can NOT contain any code, that |
|
121 // might leave. |
|
122 // |
|
123 CWVSettingsUIServersArray::CWVSettingsUIServersArray( |
|
124 MDesCArray& aServerList, |
|
125 RArray<TInt>& aProtectedServers ) |
|
126 : iServerList( &aServerList ), iProtectedServers ( &aProtectedServers ) |
|
127 { |
|
128 } |
|
129 |
|
130 // Symbian OS default constructor can leave. |
|
131 void CWVSettingsUIServersArray::ConstructL() |
|
132 { |
|
133 |
|
134 // Reserve enough memory to handle maximum size item |
|
135 iData = HBufC::NewL( KWVSettingsServerNameMaxLength + |
|
136 KServerNameFormatTrailer().Length() + |
|
137 KFirstIconFormat().Length() ); |
|
138 |
|
139 } |
|
140 // End of File |