|
1 /* |
|
2 * Copyright (c) 2007-2008 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "iaupdatestatuspanehandler.h" |
|
23 #include "iaupdatenavipanehandler.h" |
|
24 #include "iaupdatedebug.h" |
|
25 #include "iaupdatedialogutil.h" |
|
26 |
|
27 #include <akntitle.h> // CAknTitlePane |
|
28 #include <StringLoader.h> |
|
29 |
|
30 |
|
31 /******************************************************************************* |
|
32 * class CIAUpdateStatusPaneHandler |
|
33 *******************************************************************************/ |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CIAUpdateStatusPaneHandler::NewL |
|
37 // |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CIAUpdateStatusPaneHandler* CIAUpdateStatusPaneHandler::NewL( CAknAppUi* aAppUi ) |
|
42 { |
|
43 CIAUpdateStatusPaneHandler* self = new (ELeave) CIAUpdateStatusPaneHandler( aAppUi ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // Destructor |
|
53 // |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CIAUpdateStatusPaneHandler::~CIAUpdateStatusPaneHandler() |
|
57 { |
|
58 TRAP_IGNORE( RestoreOriginalTitleL() ); |
|
59 |
|
60 delete iNaviPaneHandler; |
|
61 delete iOriginalTitle; |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CIAUpdateStatusPaneHandler::ConstructL |
|
67 // |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CIAUpdateStatusPaneHandler::ConstructL() |
|
72 { |
|
73 iNaviPaneHandler = new (ELeave) CIAUpdateNaviPaneHandler( iAppUi->StatusPane() ); |
|
74 iOriginalTitle = KNullDesC().AllocL(); |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CIAUpdateStatusPaneHandler::CIAUpdateStatusPaneHandler |
|
80 // |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CIAUpdateStatusPaneHandler::CIAUpdateStatusPaneHandler( CAknAppUi* aAppUi ) : iAppUi(aAppUi ) |
|
84 { |
|
85 iOriginalTitleStored = EFalse; |
|
86 } |
|
87 |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CIAUpdateStatusPaneHandler::GetTitleL |
|
91 // |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 TBool CIAUpdateStatusPaneHandler::GetTitleL( CAknAppUi* aAppUi, HBufC*& aTitle ) |
|
95 { |
|
96 aTitle = NULL; |
|
97 |
|
98 CEikStatusPane* statusPane = aAppUi->StatusPane(); |
|
99 if (statusPane && statusPane->PaneCapabilities( |
|
100 TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
101 { |
|
102 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
103 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
104 if ( titlePane->Text() ) |
|
105 { |
|
106 aTitle = titlePane->Text()->AllocL(); |
|
107 return ETrue; |
|
108 } |
|
109 } |
|
110 |
|
111 return EFalse; |
|
112 } |
|
113 |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // CIAUpdateStatusPaneHandler::SetTitleL |
|
117 // |
|
118 // ---------------------------------------------------------------------------- |
|
119 // |
|
120 TBool CIAUpdateStatusPaneHandler::SetTitleL( CAknAppUi* aAppUi, const TDesC& aTitle ) |
|
121 { |
|
122 CEikStatusPane* statusPane = aAppUi->StatusPane(); |
|
123 if ( statusPane && statusPane->PaneCapabilities( |
|
124 TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
125 { |
|
126 CAknTitlePane* titlePane = static_cast<CAknTitlePane*> |
|
127 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
128 if ( titlePane->Text() ) |
|
129 { |
|
130 titlePane->SetTextL( aTitle ); |
|
131 return ETrue; |
|
132 } |
|
133 } |
|
134 return EFalse; |
|
135 } |
|
136 |
|
137 |
|
138 // ---------------------------------------------------------------------------- |
|
139 // CIAUpdateStatusPaneHandler::SetNaviPaneTitleL |
|
140 // |
|
141 // ---------------------------------------------------------------------------- |
|
142 // |
|
143 void CIAUpdateStatusPaneHandler::SetNaviPaneTitleL( const TDesC& aTitle ) |
|
144 { |
|
145 iNaviPaneHandler->SetNaviPaneTitleL( aTitle ); |
|
146 } |
|
147 |
|
148 |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // CIAUpdateStatusPaneHandler::StoreOriginalTitleL |
|
152 // |
|
153 // ---------------------------------------------------------------------------- |
|
154 // |
|
155 void CIAUpdateStatusPaneHandler::StoreOriginalTitleL() |
|
156 { |
|
157 delete iOriginalTitle; |
|
158 iOriginalTitle = NULL; |
|
159 TBool ret = GetTitleL( iAppUi, iOriginalTitle ); |
|
160 if ( !iOriginalTitle ) |
|
161 { |
|
162 iOriginalTitle = KNullDesC().AllocL(); |
|
163 } |
|
164 if ( ret ) |
|
165 { |
|
166 iOriginalTitleStored = ETrue; |
|
167 } |
|
168 } |
|
169 |
|
170 |
|
171 // ---------------------------------------------------------------------------- |
|
172 // CIAUpdateStatusPaneHandler::RestoreOriginalTitleL |
|
173 // |
|
174 // ---------------------------------------------------------------------------- |
|
175 // |
|
176 void CIAUpdateStatusPaneHandler::RestoreOriginalTitleL() |
|
177 { |
|
178 if ( iOriginalTitleStored ) |
|
179 { |
|
180 SetTitleL( iAppUi, *iOriginalTitle ); |
|
181 } |
|
182 } |
|
183 |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CIAUpdateStatusPaneHandler::SetTitleL |
|
187 // |
|
188 // ---------------------------------------------------------------------------- |
|
189 // |
|
190 void CIAUpdateStatusPaneHandler::SetTitleL( const TDesC& aText ) |
|
191 { |
|
192 if ( iOriginalTitleStored ) |
|
193 { |
|
194 SetTitleL( iAppUi, aText ); |
|
195 } |
|
196 } |
|
197 |
|
198 |
|
199 // ---------------------------------------------------------------------------- |
|
200 // CIAUpdateStatusPaneHandler::SetTitleL |
|
201 // |
|
202 // ---------------------------------------------------------------------------- |
|
203 // |
|
204 void CIAUpdateStatusPaneHandler::SetTitleL( TInt aResourceId ) |
|
205 { |
|
206 HBufC* hBuf = StringLoader::LoadLC( aResourceId ); |
|
207 SetTitleL( hBuf->Des() ); |
|
208 CleanupStack::PopAndDestroy( hBuf ); |
|
209 } |
|
210 |
|
211 |
|
212 // End of File |