|
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 application view factory. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2AppViewFactory.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2AppUi.h" |
|
24 #include "CPbk2ContactInfoAppView.h" |
|
25 #include "CPbk2SettingsView.h" |
|
26 #include <Pbk2ViewId.hrh> |
|
27 #include <CPbk2UIExtensionManager.h> |
|
28 #include <MPbk2UIExtensionFactory.h> |
|
29 #include <MPbk2ApplicationServices.h> |
|
30 |
|
31 // Debugging headers |
|
32 #include <Pbk2Profile.h> |
|
33 |
|
34 /// Unnamed namespace for local definitions |
|
35 namespace { |
|
36 |
|
37 #ifdef _DEBUG |
|
38 |
|
39 enum TPanicCode |
|
40 { |
|
41 EPanicUnknownViewId = 1, |
|
42 EPanicViewIdMismatch |
|
43 }; |
|
44 |
|
45 void Panic(TPanicCode aReason) |
|
46 { |
|
47 _LIT( KPanicText, "CPbk2AppViewFactory" ); |
|
48 User::Panic(KPanicText,aReason); |
|
49 } |
|
50 |
|
51 #endif // _DEBUG |
|
52 |
|
53 } /// namespace |
|
54 |
|
55 |
|
56 // -------------------------------------------------------------------------- |
|
57 // CPbk2AppViewFactory::CPbk2AppViewFactory |
|
58 // -------------------------------------------------------------------------- |
|
59 // |
|
60 inline CPbk2AppViewFactory::CPbk2AppViewFactory( CPbk2AppUi& aAppUi ): |
|
61 iAppUi( aAppUi ) |
|
62 { |
|
63 } |
|
64 |
|
65 // -------------------------------------------------------------------------- |
|
66 // CPbk2AppViewFactory::~CPbk2AppViewFactory |
|
67 // -------------------------------------------------------------------------- |
|
68 // |
|
69 CPbk2AppViewFactory::~CPbk2AppViewFactory() |
|
70 { |
|
71 Release( iExtensionManager ); |
|
72 } |
|
73 |
|
74 // -------------------------------------------------------------------------- |
|
75 // CPbk2AppViewFactory::NewL |
|
76 // -------------------------------------------------------------------------- |
|
77 // |
|
78 CPbk2AppViewFactory* CPbk2AppViewFactory::NewL( CPbk2AppUi& aAppUi ) |
|
79 { |
|
80 CPbk2AppViewFactory* self = NewLC( aAppUi ); |
|
81 CleanupStack::Pop( self ); |
|
82 return self; |
|
83 } |
|
84 |
|
85 // -------------------------------------------------------------------------- |
|
86 // CPbk2AppViewFactory::NewLC |
|
87 // -------------------------------------------------------------------------- |
|
88 // |
|
89 CPbk2AppViewFactory* CPbk2AppViewFactory::NewLC( CPbk2AppUi& aAppUi ) |
|
90 { |
|
91 CPbk2AppViewFactory* self = new ( ELeave ) CPbk2AppViewFactory( aAppUi ); |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL(); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // CPbk2AppViewFactory::ConstructL |
|
99 // -------------------------------------------------------------------------- |
|
100 // |
|
101 inline void CPbk2AppViewFactory::ConstructL() |
|
102 { |
|
103 iExtensionManager = CPbk2UIExtensionManager::InstanceL(); |
|
104 } |
|
105 |
|
106 // -------------------------------------------------------------------------- |
|
107 // CPbk2AppViewFactory::CreateAppViewL |
|
108 // -------------------------------------------------------------------------- |
|
109 // |
|
110 CAknView* CPbk2AppViewFactory::CreateAppViewL( TUid aId ) |
|
111 { |
|
112 PBK2_PROFILE_START(Pbk2Profile::EAppViewFactoryCreateAppViewL); |
|
113 CAknView* view = NULL; |
|
114 |
|
115 // Create the view object |
|
116 switch ( aId.iUid ) |
|
117 { |
|
118 case EPbk2ContactInfoViewId: |
|
119 { |
|
120 PBK2_PROFILE_START |
|
121 ( Pbk2Profile::EAppViewFactoryContactInfoAppViewNewL ); |
|
122 view = CPbk2ContactInfoAppView::NewL |
|
123 ( iAppUi.ApplicationServices().ContactManager() ); |
|
124 PBK2_PROFILE_END |
|
125 ( Pbk2Profile::EAppViewFactoryContactInfoAppViewNewL ); |
|
126 break; |
|
127 } |
|
128 case EPbk2SettingsViewId: |
|
129 { |
|
130 PBK2_PROFILE_START |
|
131 ( Pbk2Profile::EAppViewFactorySettingsAppViewNewL ); |
|
132 view = CPbk2SettingsView::NewL(); |
|
133 PBK2_PROFILE_END |
|
134 ( Pbk2Profile::EAppViewFactorySettingsAppViewNewL ); |
|
135 break; |
|
136 } |
|
137 default: |
|
138 { |
|
139 // If the view is not created by any of the cases above, |
|
140 // we know that the view is brought by some extension because |
|
141 // the views are created based on the view graph definition |
|
142 view = iExtensionManager->FactoryL()-> |
|
143 CreatePhonebook2ViewL( aId ); |
|
144 break; |
|
145 } |
|
146 } |
|
147 |
|
148 __ASSERT_DEBUG( view, Panic( EPanicUnknownViewId ) ); |
|
149 __ASSERT_DEBUG( view->Id() == aId, Panic( EPanicViewIdMismatch ) ); |
|
150 |
|
151 // Return the created view object |
|
152 PBK2_PROFILE_END(Pbk2Profile::EAppViewFactoryCreateAppViewL); |
|
153 return view; |
|
154 } |
|
155 |
|
156 // -------------------------------------------------------------------------- |
|
157 // CPbk2AppViewFactory::CreateAppViewLC |
|
158 // -------------------------------------------------------------------------- |
|
159 // |
|
160 CAknView* CPbk2AppViewFactory::CreateAppViewLC( TUid aId ) |
|
161 { |
|
162 CAknView* view = CreateAppViewL( aId ); |
|
163 CleanupStack::PushL( view ); |
|
164 return view; |
|
165 } |
|
166 |
|
167 // End of File |