|
1 /* |
|
2 * Copyright (c) 2007 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: This file implements classes CIpsSetUiCtrlPageResource, Resource. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <cstack.h> // CStack |
|
21 |
|
22 #include "ipssetutilsexception.h" |
|
23 #include "ipssetuictrlpageresource.h" |
|
24 |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // CIpsSetUiCtrlPageResource::CIpsSetUiCtrlPageResource() |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 CIpsSetUiCtrlPageResource::CIpsSetUiCtrlPageResource() |
|
33 { |
|
34 FUNC_LOG; |
|
35 } |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // CIpsSetUiCtrlPageResource::~CIpsSetUiCtrlPageResource() |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 CIpsSetUiCtrlPageResource::~CIpsSetUiCtrlPageResource() |
|
42 { |
|
43 FUNC_LOG; |
|
44 if ( iPageResources ) |
|
45 { |
|
46 iPageResources->ResetAndDestroy(); |
|
47 } |
|
48 |
|
49 delete iPageResources; |
|
50 iPageResources = NULL; |
|
51 } |
|
52 |
|
53 // ---------------------------------------------------------------------------- |
|
54 // CIpsSetUiCtrlPageResource::ConstructL() |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 void CIpsSetUiCtrlPageResource::ConstructL() |
|
58 { |
|
59 FUNC_LOG; |
|
60 iPageResources = new ( ELeave ) CResourceStackArray( EIpsSetUiLastPage ); |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CIpsSetUiCtrlPageResource::NewL() |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CIpsSetUiCtrlPageResource* CIpsSetUiCtrlPageResource::NewL() |
|
68 { |
|
69 FUNC_LOG; |
|
70 CIpsSetUiCtrlPageResource* self = NewLC(); |
|
71 CleanupStack::Pop( self ); |
|
72 |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CIpsSetUiCtrlPageResource::NewLC() |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 CIpsSetUiCtrlPageResource* CIpsSetUiCtrlPageResource::NewLC() |
|
81 { |
|
82 FUNC_LOG; |
|
83 CIpsSetUiCtrlPageResource* self = new ( ELeave ) CIpsSetUiCtrlPageResource(); |
|
84 CleanupStack::PushL( self ); |
|
85 self->ConstructL(); |
|
86 |
|
87 return self; |
|
88 } |
|
89 |
|
90 /****************************************************************************** |
|
91 |
|
92 |
|
93 |
|
94 ******************************************************************************/ |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // CIpsSetUiCtrlPageResource::PushResourceL() |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 void CIpsSetUiCtrlPageResource::PushResourceL( |
|
101 const TInt aType, |
|
102 const TInt aPageResource ) |
|
103 { |
|
104 FUNC_LOG; |
|
105 Stack( aType ).AppendL( aPageResource ); |
|
106 } |
|
107 |
|
108 // ---------------------------------------------------------------------------- |
|
109 // CIpsSetUiCtrlPageResource::Resource() |
|
110 // ---------------------------------------------------------------------------- |
|
111 // |
|
112 TInt CIpsSetUiCtrlPageResource::Resource( |
|
113 const TInt aType, |
|
114 const TBool aRemove ) |
|
115 { |
|
116 FUNC_LOG; |
|
117 CResourceStack& stack = Stack( aType ); |
|
118 TInt index = stack.Count() - 1; |
|
119 if ( !aRemove || aRemove && !index ) |
|
120 { |
|
121 return stack[index]; |
|
122 } |
|
123 else |
|
124 { |
|
125 TInt resource = stack[index]; |
|
126 stack.Delete( index ); |
|
127 return resource; |
|
128 } |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // CIpsSetUiCtrlPageResource::Count() |
|
133 // ---------------------------------------------------------------------------- |
|
134 // |
|
135 TInt CIpsSetUiCtrlPageResource::Count( const TInt aType ) |
|
136 { |
|
137 FUNC_LOG; |
|
138 return Stack( aType ).Count(); |
|
139 } |
|
140 |
|
141 // ---------------------------------------------------------------------------- |
|
142 // CIpsSetUiCtrlPageResource::CreateStackL() |
|
143 // ---------------------------------------------------------------------------- |
|
144 // |
|
145 CResourceStack* CIpsSetUiCtrlPageResource::CreateStackL( |
|
146 const TInt aPageResource ) |
|
147 { |
|
148 FUNC_LOG; |
|
149 IPS_ASSERT_DEBUG( iPageResources , EArrayNull, EPageResource ); |
|
150 |
|
151 CResourceStack* stack = new ( ELeave ) CResourceStack( EIpsSetUiLastPage ); |
|
152 CleanupStack::PushL( stack ); |
|
153 |
|
154 iPageResources->AppendL( stack ); |
|
155 stack->AppendL( aPageResource ); |
|
156 |
|
157 CleanupStack::Pop( stack ); |
|
158 |
|
159 return stack; |
|
160 } |
|
161 |
|
162 // ---------------------------------------------------------------------------- |
|
163 // CIpsSetUiCtrlPageResource::operator[]() |
|
164 // ---------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CIpsSetUiCtrlPageResource::operator[]( const TInt aType ) |
|
167 { |
|
168 FUNC_LOG; |
|
169 return Resource( aType ); |
|
170 } |
|
171 |
|
172 /****************************************************************************** |
|
173 |
|
174 TOOLS |
|
175 |
|
176 ******************************************************************************/ |
|
177 |
|
178 |
|
179 // ---------------------------------------------------------------------------- |
|
180 // CIpsSetUiCtrlPageResource::Stack() |
|
181 // ---------------------------------------------------------------------------- |
|
182 // |
|
183 CResourceStack& CIpsSetUiCtrlPageResource::Stack( const TInt aType ) |
|
184 { |
|
185 FUNC_LOG; |
|
186 IPS_ASSERT_DEBUG( iPageResources->Count(), EStackEmpty, EPageResource ); |
|
187 IPS_ASSERT_DEBUG( aType < iPageResources->Count(), EUnknownType, EPageResource ); |
|
188 IPS_ASSERT_DEBUG( ( *iPageResources )[aType] , EStackNull, EPageResource ); |
|
189 IPS_ASSERT_DEBUG( iPageResources , EArrayNull, EPageResource ); |
|
190 |
|
191 return *( *iPageResources )[aType]; |
|
192 } |
|
193 |
|
194 // End of File |
|
195 |