|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 view explorer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2ViewExplorer.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2ViewActivationTransaction.h" |
|
24 #include "CPbk2ViewState.h" |
|
25 #include "CPbk2AppViewFactory.h" |
|
26 #include "CPbk2AppUi.h" |
|
27 #include "CPbk2Document.h" |
|
28 #include <Phonebook2.rsg> |
|
29 #include <CPbk2ViewGraph.h> |
|
30 #include <CPbk2AppViewBase.h> |
|
31 #include <CPbk2IconInfoContainer.h> |
|
32 #include <CPbk2IconFactory.h> |
|
33 #include <CPbk2UIExtensionManager.h> |
|
34 #include <Pbk2UID.h> |
|
35 #include <TPbk2IconId.h> |
|
36 |
|
37 // System includes |
|
38 #include <barsread.h> |
|
39 #include <aknnavide.h> |
|
40 #include <eikapp.h> |
|
41 #include <aknview.h> |
|
42 |
|
43 // Debugging headers |
|
44 #include <Pbk2Debug.h> |
|
45 #include <Pbk2Profile.h> |
|
46 |
|
47 |
|
48 /// Unnamed namespace for local definitions |
|
49 namespace { |
|
50 |
|
51 #ifdef _DEBUG |
|
52 |
|
53 enum TPanicCode |
|
54 { |
|
55 EPanicPreCond_ConstructL = 1, |
|
56 EPanicPostCond_ConstructL, |
|
57 }; |
|
58 |
|
59 void Panic(TPanicCode aReason) |
|
60 { |
|
61 _LIT( KPanicText, "CPbk2ViewExplorer" ); |
|
62 User::Panic( KPanicText, aReason ); |
|
63 } |
|
64 |
|
65 #endif // _DEBUG |
|
66 |
|
67 } /// namespace |
|
68 |
|
69 |
|
70 // -------------------------------------------------------------------------- |
|
71 // CPbk2ViewExplorer::CPbk2ViewExplorer |
|
72 // -------------------------------------------------------------------------- |
|
73 // |
|
74 CPbk2ViewExplorer::CPbk2ViewExplorer( CPbk2AppUi& aAppUi ) : |
|
75 iAppUi( aAppUi ) |
|
76 { |
|
77 } |
|
78 |
|
79 // -------------------------------------------------------------------------- |
|
80 // CPbk2ViewExplorer::~CPbk2ViewExplorer |
|
81 // -------------------------------------------------------------------------- |
|
82 // |
|
83 CPbk2ViewExplorer::~CPbk2ViewExplorer() |
|
84 { |
|
85 delete iViewGraph; |
|
86 } |
|
87 |
|
88 // -------------------------------------------------------------------------- |
|
89 // CPbk2ViewExplorer::NewL |
|
90 // -------------------------------------------------------------------------- |
|
91 // |
|
92 CPbk2ViewExplorer* CPbk2ViewExplorer::NewL( CPbk2AppUi& aAppUi ) |
|
93 { |
|
94 CPbk2ViewExplorer* self = |
|
95 new ( ELeave ) CPbk2ViewExplorer( aAppUi ); |
|
96 CleanupStack::PushL( self ); |
|
97 self->ConstructL(); |
|
98 CleanupStack::Pop( self ); |
|
99 return self; |
|
100 } |
|
101 |
|
102 // -------------------------------------------------------------------------- |
|
103 // CPbk2ViewExplorer::ConstructL |
|
104 // -------------------------------------------------------------------------- |
|
105 // |
|
106 void CPbk2ViewExplorer::ConstructL() |
|
107 { |
|
108 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
109 ("CPbk2ViewExplorer::ConstructL(0x%x)"), this); |
|
110 |
|
111 __ASSERT_DEBUG( !iViewGraph, Panic( EPanicPreCond_ConstructL ) ); |
|
112 |
|
113 // Create UI elements |
|
114 PBK2_PROFILE_START(Pbk2Profile::EViewExplorerConstructionReadViewGraph); |
|
115 // Read view graph from resources and apply |
|
116 // UI extension view graph changes |
|
117 ReadViewGraphL(); |
|
118 PBK2_PROFILE_END(Pbk2Profile::EViewExplorerConstructionReadViewGraph); |
|
119 |
|
120 __ASSERT_DEBUG( iViewGraph , Panic( EPanicPostCond_ConstructL ) ); |
|
121 |
|
122 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
123 ("CPbk2ViewExplorer::ConstructL end")); |
|
124 } |
|
125 |
|
126 // -------------------------------------------------------------------------- |
|
127 // CPbk2ViewExplorer::CreateViewsL |
|
128 // -------------------------------------------------------------------------- |
|
129 // |
|
130 void CPbk2ViewExplorer::CreateViewsL() |
|
131 { |
|
132 PBK2_PROFILE_START(Pbk2Profile::EViewExplorerCreateAppViewFactory); |
|
133 CPbk2AppViewFactory* factory = CPbk2AppViewFactory::NewLC( iAppUi ); |
|
134 PBK2_PROFILE_END(Pbk2Profile::EViewExplorerCreateAppViewFactory); |
|
135 |
|
136 // Create and add application views |
|
137 for (TInt i = 0; i < iViewGraph->Count(); ++i) |
|
138 { |
|
139 const CPbk2ViewNode& viewNode = (*iViewGraph)[i]; |
|
140 if (!viewNode.ExitNode()) |
|
141 { |
|
142 PBK2_PROFILE_START(Pbk2Profile::EViewExplorerCreateAppView); |
|
143 CAknView* view = factory->CreateAppViewLC( viewNode.ViewId() ); |
|
144 PBK2_PROFILE_END(Pbk2Profile::EViewExplorerCreateAppView); |
|
145 |
|
146 PBK2_PROFILE_START(Pbk2Profile::EViewExplorerAddView); |
|
147 iAppUi.AddViewL( view ); |
|
148 PBK2_PROFILE_END(Pbk2Profile::EViewExplorerAddView); |
|
149 CleanupStack::Pop( view ); |
|
150 } |
|
151 } |
|
152 CleanupStack::PopAndDestroy( factory ); |
|
153 } |
|
154 |
|
155 // -------------------------------------------------------------------------- |
|
156 // CPbk2ViewExplorer::IsPhonebook2View |
|
157 // -------------------------------------------------------------------------- |
|
158 // |
|
159 TBool CPbk2ViewExplorer::IsPhonebook2View |
|
160 ( const TVwsViewId& aViewId ) const |
|
161 { |
|
162 TBool ret = EFalse; |
|
163 |
|
164 if ( aViewId.iAppUid == iAppUi.Application()->AppDllUid() ) |
|
165 { |
|
166 const CPbk2ViewNode* viewNode = iViewGraph->FindNodeWithViewId |
|
167 ( aViewId.iViewUid ); |
|
168 ret = viewNode && !viewNode->ExitNode(); |
|
169 } |
|
170 |
|
171 return ret; |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CPbk2ViewExplorer::ActivatePhonebook2ViewL |
|
176 // -------------------------------------------------------------------------- |
|
177 // |
|
178 void CPbk2ViewExplorer::ActivatePhonebook2ViewL |
|
179 (TUid aViewId, const CPbk2ViewState* aViewState ) const |
|
180 { |
|
181 if ( aViewState ) |
|
182 { |
|
183 HBufC8* stateBuf = aViewState->PackLC(); |
|
184 iAppUi.ActivateLocalViewL |
|
185 ( aViewId, CPbk2ViewState::Uid(), *stateBuf ); |
|
186 CleanupStack::PopAndDestroy(); // stateBuf |
|
187 } |
|
188 else |
|
189 { |
|
190 iAppUi.ActivateLocalViewL( aViewId ); |
|
191 } |
|
192 } |
|
193 |
|
194 // -------------------------------------------------------------------------- |
|
195 // CPbk2ViewExplorer::ActivatePreviousViewL |
|
196 // -------------------------------------------------------------------------- |
|
197 // |
|
198 void CPbk2ViewExplorer::ActivatePreviousViewL |
|
199 ( const CPbk2ViewState* aViewState ) |
|
200 { |
|
201 // Find current view in the graph |
|
202 CPbk2ViewNode* viewNode = |
|
203 iViewGraph->FindNodeWithViewId( iAppUi.ActiveView()->Id() ); |
|
204 |
|
205 if ( viewNode ) |
|
206 { |
|
207 // Get previous node |
|
208 CPbk2ViewNode* prevNode = viewNode->PreviousNode(); |
|
209 if ( !prevNode ) |
|
210 { |
|
211 prevNode = viewNode->DefaultPreviousNode(); |
|
212 } |
|
213 if ( prevNode ) |
|
214 { |
|
215 if ( prevNode->ExitNode() ) |
|
216 { |
|
217 iAppUi.ExitL(); |
|
218 } |
|
219 else |
|
220 { |
|
221 ActivatePhonebook2ViewL( prevNode->ViewId(), aViewState ); |
|
222 } |
|
223 } |
|
224 } |
|
225 } |
|
226 |
|
227 // -------------------------------------------------------------------------- |
|
228 // CPbk2ViewExplorer::HandleViewActivationLC |
|
229 // -------------------------------------------------------------------------- |
|
230 // |
|
231 MPbk2ViewActivationTransaction* CPbk2ViewExplorer::HandleViewActivationLC |
|
232 ( const TUid& aViewId, const TVwsViewId& aPrevViewId, |
|
233 const TDesC* aTitlePaneText, const CEikImage* aContextPanePicture, |
|
234 TUint aFlags ) |
|
235 { |
|
236 // Create and return an instance of view activation transaction |
|
237 return CPbk2ViewActivationTransaction::NewLC |
|
238 ( iAppUi, *this, aViewId, aPrevViewId, aTitlePaneText, |
|
239 aContextPanePicture, aFlags ); |
|
240 } |
|
241 |
|
242 // -------------------------------------------------------------------------- |
|
243 // CPbk2ViewExplorer::ViewGraph |
|
244 // -------------------------------------------------------------------------- |
|
245 // |
|
246 CPbk2ViewGraph& CPbk2ViewExplorer::ViewGraph() const |
|
247 { |
|
248 return *iViewGraph; |
|
249 } |
|
250 |
|
251 // -------------------------------------------------------------------------- |
|
252 // CPbk2ViewExplorer::ReadViewGraphL |
|
253 // Loads view navigation graph from resources. |
|
254 // -------------------------------------------------------------------------- |
|
255 // |
|
256 void CPbk2ViewExplorer::ReadViewGraphL() |
|
257 { |
|
258 TResourceReader reader; |
|
259 CCoeEnv::Static()->CreateResourceReaderLC( reader, R_PBK2_VIEWNODES ); |
|
260 iViewGraph = CPbk2ViewGraph::NewL( reader ); |
|
261 CleanupStack::PopAndDestroy(); // reader |
|
262 |
|
263 iAppUi.PhonebookDocument()->ExtensionManager(). |
|
264 ApplyExtensionViewGraphChangesL( *iViewGraph ); |
|
265 } |
|
266 |
|
267 // End of File |