79
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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 |
* Messaging Centre application "Delivery Reports" view class
|
|
16 |
* implementation.
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
// INCLUDE FILES
|
|
23 |
|
|
24 |
|
|
25 |
#include <eikmenub.h>
|
|
26 |
#include <aknappui.h>
|
|
27 |
#include <AknQueryDialog.h>
|
|
28 |
#include <featmgr.h>
|
|
29 |
|
|
30 |
#include <avkon.hrh>
|
|
31 |
#include <avkon.rsg>
|
|
32 |
#include <Sendnorm.rsg>
|
|
33 |
#include <eikdialg.h>
|
|
34 |
#include <eikenv.h>
|
|
35 |
#include <f32file.h>
|
|
36 |
#include <StringLoader.h>
|
|
37 |
#include <akntitle.h>
|
|
38 |
//#include <CPhCltDialer.h>
|
|
39 |
#include <mce.rsg>
|
|
40 |
|
|
41 |
#include "MceDeliveryReportView.h"
|
|
42 |
#include "MceDeliveryReportControlContainer.h"
|
|
43 |
#include "MceApplication.h"
|
|
44 |
#include "MceDocument.h"
|
|
45 |
#include "mceui.h"
|
|
46 |
#include "MceCommands.hrh" // UID enumeration.
|
|
47 |
#include "MceLogEngine.h"
|
|
48 |
|
|
49 |
#include <commonphoneparser.h>
|
|
50 |
#include <PhCltTypes.h>
|
|
51 |
#include <MuiuMsvUiServiceUtilities.h>
|
|
52 |
#include <e32cmn.h>
|
|
53 |
#include <msvapi.h>
|
|
54 |
#include "MceSessionHolder.h"
|
|
55 |
|
|
56 |
// For Muiu split
|
|
57 |
#include <muiumsvuiserviceutilitiesinternal.h>
|
|
58 |
|
|
59 |
// The position of the middle soft key
|
|
60 |
const TInt KMSKPosition = 3;
|
|
61 |
|
|
62 |
|
|
63 |
// ================= MEMBER FUNCTIONS =======================
|
|
64 |
|
|
65 |
CMceDeliveryReportView* CMceDeliveryReportView::NewL( CMceSessionHolder& aSessionHolder )
|
|
66 |
{
|
|
67 |
CMceDeliveryReportView* self = new(ELeave) CMceDeliveryReportView(aSessionHolder);
|
|
68 |
CleanupStack::PushL(self);
|
|
69 |
self->ConstructL();
|
|
70 |
CleanupStack::Pop( self );
|
|
71 |
return self;
|
|
72 |
}
|
|
73 |
|
|
74 |
CMceDeliveryReportView::CMceDeliveryReportView( CMceSessionHolder& aSessionHolder ) :
|
|
75 |
iSessionHolder(aSessionHolder)
|
|
76 |
{
|
|
77 |
iSessionHolder.AddClient();
|
|
78 |
}
|
|
79 |
|
|
80 |
CMceDeliveryReportView::~CMceDeliveryReportView()
|
|
81 |
{
|
|
82 |
iCoeEnv->RemoveForegroundObserver( *this );
|
|
83 |
|
|
84 |
if (iContainer)
|
|
85 |
{
|
|
86 |
AppUi()->RemoveFromViewStack(*this,iContainer);
|
|
87 |
|
|
88 |
// Destroy the control container
|
|
89 |
delete iContainer;
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
ClosePopup();
|
|
94 |
|
|
95 |
FeatureManager::UnInitializeLib();
|
|
96 |
iSessionHolder.RemoveClient();
|
|
97 |
}
|
|
98 |
|
|
99 |
CMceUi* CMceDeliveryReportView::MceAppUi()
|
|
100 |
{
|
|
101 |
// Explicit cast: the app ui must always be of type CMceUi.
|
|
102 |
return STATIC_CAST( CMceUi*, CAknView::AppUi() );
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
void CMceDeliveryReportView::HandleCommandL( TInt aCommandId )
|
|
107 |
{
|
|
108 |
switch (aCommandId )
|
|
109 |
{
|
|
110 |
case EMceCmdCall:
|
|
111 |
{
|
|
112 |
if( iPopup )
|
|
113 |
{
|
|
114 |
iPopup->StopDisplayingMenuBar();
|
|
115 |
ClosePopup();
|
|
116 |
}
|
|
117 |
TInt index( 0 );
|
|
118 |
index = iContainer->ListBox()->CurrentItemIndex();
|
|
119 |
TPhCltTelephoneNumber tel;
|
|
120 |
tel = MceAppUi()->LogEngine()->Event( index )->Number();
|
|
121 |
|
|
122 |
// Check the validity of the phone number and initiate the call
|
|
123 |
TBool validNumber = CommonPhoneParser::ParsePhoneNumber( tel, CommonPhoneParser::EPlainPhoneNumber );
|
|
124 |
if ( validNumber )
|
|
125 |
{
|
|
126 |
TPhCltNameBuffer recipientstring( KNullDesC );
|
|
127 |
iAvkonAppUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | CAknAppUiBase::EDisableSendKeyLong );
|
|
128 |
MsvUiServiceUtilitiesInternal::CallToSenderQueryL( tel, recipientstring, ETrue );
|
|
129 |
iAvkonAppUi->SetKeyEventFlags( 0x00 );
|
|
130 |
}
|
|
131 |
}
|
|
132 |
break;
|
|
133 |
case EMceClearDrList:
|
|
134 |
{
|
|
135 |
CAknQueryDialog* queryDlg = CAknQueryDialog::NewL();
|
|
136 |
if( queryDlg->ExecuteLD( R_MCE_CLEAR_LIST_CONFIRMATION_QUERY ) )
|
|
137 |
{
|
|
138 |
MceAppUi()->LogEngine()->ClearDrListL();
|
|
139 |
}
|
|
140 |
SetMSKButtonL();
|
|
141 |
}
|
|
142 |
break;
|
|
143 |
case EAknCmdHideInBackground:
|
|
144 |
// handled by app ui and sent directly to appui by avkon framework so ignore this by view.
|
|
145 |
break;
|
|
146 |
default:
|
|
147 |
MceAppUi()->HandleCommandL( aCommandId );
|
|
148 |
break;
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
|
|
153 |
TUid CMceDeliveryReportView::Id() const
|
|
154 |
{
|
|
155 |
return KMceDeliveryReportViewId;
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
void CMceDeliveryReportView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
160 |
{
|
|
161 |
TInt aPosition = -1;
|
|
162 |
|
|
163 |
if( aMenuPane->MenuItemExists( EAknCmdHelp, aPosition ) )
|
|
164 |
{
|
|
165 |
// KFeatureIdHelp is used by Feature Mgr to check if help is supported
|
|
166 |
if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
|
|
167 |
{
|
|
168 |
aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
|
|
169 |
}
|
|
170 |
else
|
|
171 |
{
|
|
172 |
aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
|
176 |
switch( aResourceId )
|
|
177 |
{
|
|
178 |
case R_MCE_DELIVERY_REPORT_SYSTEM_MENU:
|
|
179 |
|
|
180 |
if( ! MceAppUi()->LogEngine()->
|
|
181 |
IsNumberAvailable( iContainer->ListBox()->CurrentItemIndex() ) )
|
|
182 |
{
|
|
183 |
if ( aMenuPane->MenuItemExists( EMceCmdCall, aPosition ) )
|
|
184 |
{
|
|
185 |
aMenuPane->DeleteMenuItem( EMceCmdCall );
|
|
186 |
}
|
|
187 |
}
|
|
188 |
|
|
189 |
if ( iContainer->ListBox()->Model()->NumberOfItems() == 0 )
|
|
190 |
{
|
|
191 |
aMenuPane->DeleteMenuItem( EMceClearDrList );
|
|
192 |
}
|
|
193 |
break;
|
|
194 |
|
|
195 |
default:
|
|
196 |
break;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
|
|
201 |
void CMceDeliveryReportView::HandleClientRectChange()
|
|
202 |
{
|
|
203 |
iContainer->SetRect(ClientRect());
|
|
204 |
}
|
|
205 |
|
|
206 |
void CMceDeliveryReportView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
|
|
207 |
TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
|
|
208 |
{
|
|
209 |
if ( iContainer == NULL )
|
|
210 |
{
|
|
211 |
// Create the control container
|
|
212 |
iContainer = CMceDeliveryReportControlContainer::NewL(this, iSessionHolder, ClientRect() );
|
|
213 |
AppUi()->AddToViewStackL(*this,iContainer);
|
|
214 |
}
|
|
215 |
iContainer->ListBox()->SetListBoxObserver(this);
|
|
216 |
|
|
217 |
|
|
218 |
// Fetch pointer to the default title pane control
|
|
219 |
CAknTitlePane* title=(CAknTitlePane *)StatusPane()->ControlL(
|
|
220 |
TUid::Uid(EEikStatusPaneUidTitle));
|
|
221 |
HBufC* text = StringLoader::LoadLC( R_MCE_DELIVERY_REPORTS_VIEW_TITLE );
|
|
222 |
title->SetTextL( *text );
|
|
223 |
CleanupStack::PopAndDestroy(); // text
|
|
224 |
|
|
225 |
MceAppUi()->SetMceViewActive( EMceDeliveryReportsViewActive );
|
|
226 |
|
|
227 |
// Just ignore if this leaves. Worst thing happens here is that user sees empty delivery reports view.
|
|
228 |
TRAP_IGNORE( MceAppUi()->LogEngine()->ForegroundGainedL() );
|
|
229 |
if( iContainer->LogDisabledL() == KMceDRLogingOff )
|
|
230 |
{
|
|
231 |
iContainer->PopUpNoteL();
|
|
232 |
}
|
|
233 |
}
|
|
234 |
|
|
235 |
void CMceDeliveryReportView::DoDeactivate()
|
|
236 |
{
|
|
237 |
if (iContainer)
|
|
238 |
{
|
|
239 |
// Remove view and its control from the view stack
|
|
240 |
AppUi()->RemoveFromViewStack(*this, iContainer);
|
|
241 |
|
|
242 |
// Destroy the container control
|
|
243 |
delete iContainer;
|
|
244 |
iContainer = NULL;
|
|
245 |
}
|
|
246 |
}
|
|
247 |
|
|
248 |
void CMceDeliveryReportView::ConstructL()
|
|
249 |
{
|
|
250 |
// Sets up TLS, must be done before FeatureManager is used.
|
|
251 |
FeatureManager::InitializeLibL();
|
|
252 |
|
|
253 |
// Init base class
|
|
254 |
BaseConstructL( R_MCE_DELIVERY_REPORT_VIEW );
|
|
255 |
iCoeEnv->AddForegroundObserverL( *this );
|
|
256 |
}
|
|
257 |
|
|
258 |
void CMceDeliveryReportView::HandleListBoxEventL(
|
|
259 |
CEikListBox* /*aListBox*/,
|
|
260 |
TListBoxEvent aEventType)
|
|
261 |
{
|
|
262 |
if ( aEventType == EEventItemSingleClicked )
|
|
263 |
{
|
|
264 |
ProcessCommandL( EAknSoftkeyContextOptions );
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
void CMceDeliveryReportView::LaunchPopupMenuL( TInt aResourceId )
|
|
269 |
{
|
|
270 |
ClosePopup();
|
|
271 |
iPopup = new ( ELeave ) CEikMenuBar;
|
|
272 |
TRAPD( err, DoLaunchPopupL( aResourceId ) );
|
|
273 |
if( err )
|
|
274 |
{
|
|
275 |
ClosePopup();
|
|
276 |
User::Leave( err );
|
|
277 |
}
|
|
278 |
}
|
|
279 |
|
|
280 |
void CMceDeliveryReportView::ClosePopup()
|
|
281 |
{
|
|
282 |
if( iPopup )
|
|
283 |
{
|
|
284 |
AppUi()->RemoveFromViewStack( *this, iPopup );
|
|
285 |
delete( iPopup );
|
|
286 |
iPopup = NULL;
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
void CMceDeliveryReportView::DoLaunchPopupL( TInt aResourceId )
|
|
291 |
{
|
|
292 |
iPopup->ConstructL( this, 0, aResourceId );
|
|
293 |
AppUi()->AddToViewStackL( *this, iPopup, ECoeStackPriorityMenu,
|
|
294 |
ECoeStackFlagRefusesFocus );
|
|
295 |
iPopup->SetMenuType(CEikMenuBar::EMenuContext);
|
|
296 |
iPopup->TryDisplayMenuBarL();
|
|
297 |
}
|
|
298 |
|
|
299 |
|
|
300 |
void CMceDeliveryReportView::HandleGainingForeground()
|
|
301 |
{
|
|
302 |
if ( MceAppUi()->MceViewActive( EMceDeliveryReportsViewActive ) )
|
|
303 |
{
|
|
304 |
// Just ignore if this leaves. Worst thing happens here is that user sees empty delivery reports view.
|
|
305 |
TRAP_IGNORE( MceAppUi()->LogEngine()->ForegroundGainedL() );
|
|
306 |
}
|
|
307 |
}
|
|
308 |
|
|
309 |
void CMceDeliveryReportView::HandleLosingForeground()
|
|
310 |
{
|
|
311 |
MceAppUi()->LogEngine()->ForegroundLost();
|
|
312 |
}
|
|
313 |
|
|
314 |
void CMceDeliveryReportView::ProcessCommandL( TInt aCommand )
|
|
315 |
{
|
|
316 |
TInt index( 0 );
|
|
317 |
TBool validNumber = EFalse ;
|
|
318 |
index = iContainer->ListBox()->CurrentItemIndex();
|
|
319 |
if ( index >= 0 )
|
|
320 |
{
|
|
321 |
TPhCltTelephoneNumber tel;
|
|
322 |
tel = MceAppUi()->LogEngine()->Event( index )->Number();
|
|
323 |
// Check the validity of the phone number and initiate the call
|
|
324 |
validNumber = CommonPhoneParser::ParsePhoneNumber( tel, CommonPhoneParser::EPlainPhoneNumber );
|
|
325 |
}
|
|
326 |
if ( validNumber && aCommand == EAknSoftkeyContextOptions )
|
|
327 |
{
|
|
328 |
aCommand = EAknSoftkeyOptions;
|
|
329 |
MenuBar()->SetMenuTitleResourceId( R_MCE_DELIVERY_REPORT_OK_MENUBAR );
|
|
330 |
MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
|
|
331 |
}
|
|
332 |
else
|
|
333 |
{
|
|
334 |
MenuBar()->SetMenuTitleResourceId( R_MCE_DELIVERY_REPORT_MENUBAR );
|
|
335 |
MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);
|
|
336 |
}
|
|
337 |
|
|
338 |
CAknView::ProcessCommandL( aCommand );
|
|
339 |
}
|
|
340 |
|
|
341 |
void CMceDeliveryReportView::SetMSKButtonL()
|
|
342 |
{
|
|
343 |
TInt resourceId = R_MCE_MSK_BUTTON_CONTEXT_OPTIONS;
|
|
344 |
if ( iContainer->ListBox()->Model()->NumberOfItems() == 0 ||
|
|
345 |
!MceAppUi()->LogEngine()->
|
|
346 |
IsNumberAvailable( iContainer->ListBox()->CurrentItemIndex() ) )
|
|
347 |
{
|
|
348 |
resourceId = R_MCE_MSK_BUTTON_EMPTY;
|
|
349 |
}
|
|
350 |
CEikButtonGroupContainer* cba = Cba();
|
|
351 |
cba->SetCommandL( KMSKPosition, resourceId );
|
|
352 |
cba->DrawDeferred();
|
|
353 |
}
|
|
354 |
|
|
355 |
// End of File
|