1
/* $Id: symbian_ua_guiContainerView.cpp 3550 2011-05-05 05:33:27Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
// [[[ begin generated region: do not modify [Generated System Includes]
20
#include <aknviewappui.h>
24
#include <stringloader.h>
29
#include <akncontext.h>
32
#include <aknnotewrappers.h>
33
#include <aknquerydialog.h>
34
#include <symbian_ua_gui.rsg>
35
// ]]] end generated region [Generated System Includes]
37
// [[[ begin generated region: do not modify [Generated User Includes]
38
#include "symbian_ua_gui.hrh"
39
#include "symbian_ua_guiContainerView.h"
40
#include "symbian_ua_guiContainer.hrh"
41
#include "symbian_ua_guiSettingItemList.hrh"
42
#include "symbian_ua_guiContainer.h"
43
// ]]] end generated region [Generated User Includes]
46
#include "symbian_ua.h"
48
// [[[ begin generated region: do not modify [Generated Constants]
49
// ]]] end generated region [Generated Constants]
51
Csymbian_ua_guiContainerView *myinstance = NULL;
52
_LIT(KStCall, "Call");
53
_LIT(KStHangUp, "Hang Up");
55
void on_info(const wchar_t* buf)
57
TPtrC aBuf((const TUint16*)buf);
60
myinstance->PutMessage(aBuf);
63
void on_incoming_call(const wchar_t* caller_disp, const wchar_t* caller_uri)
66
TPtrC aDisp((const TUint16*)caller_disp);
67
TPtrC aUri((const TUint16*)caller_uri);
68
_LIT(KFormat, "Incoming call from %S, accept?");
70
buf.Format(KFormat, &aDisp);
71
if (Csymbian_ua_guiContainerView::RunQry_accept_callL(&buf) == EAknSoftkeyYes)
73
CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
75
TRAPD(result, cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStHangUp));
78
symbian_ua_answercall();
84
void on_call_end(const wchar_t* reason)
86
TPtrC aReason((const TUint16*)reason);
88
CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
90
TRAPD(result, cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStCall));
94
Csymbian_ua_guiContainerView::RunNote_infoL(&aReason);
97
void on_reg_state(bool success)
100
Csymbian_ua_guiContainerView::RunNote_infoL();
102
Csymbian_ua_guiContainerView::RunNote_warningL();
105
void on_unreg_state(bool success)
107
TPtrC st_success(_L("Unregistration Success!"));
108
TPtrC st_failed(_L("Unregistration Failed!"));
111
Csymbian_ua_guiContainerView::RunNote_infoL(&st_success);
113
Csymbian_ua_guiContainerView::RunNote_warningL(&st_failed);
116
void Csymbian_ua_guiContainerView::PutMessage(const TDesC &msg)
118
if (!iSymbian_ua_guiContainer)
121
CEikEdwin *obj_info = (CEikEdwin*) iSymbian_ua_guiContainer->ComponentControl(iSymbian_ua_guiContainer->EEd_info);
123
obj_info->SetTextL(&msg);
124
obj_info->DrawDeferred();
128
* First phase of Symbian two-phase construction. Should not contain any
129
* code that could leave.
131
Csymbian_ua_guiContainerView::Csymbian_ua_guiContainerView()
133
// [[[ begin generated region: do not modify [Generated Contents]
134
iSymbian_ua_guiContainer = NULL;
135
// ]]] end generated region [Generated Contents]
139
* The view's destructor removes the container from the control
140
* stack and destroys it.
142
Csymbian_ua_guiContainerView::~Csymbian_ua_guiContainerView()
144
// [[[ begin generated region: do not modify [Generated Contents]
145
delete iSymbian_ua_guiContainer;
146
iSymbian_ua_guiContainer = NULL;
147
// ]]] end generated region [Generated Contents]
149
symbian_ua_set_info_callback(NULL);
154
* Symbian two-phase constructor.
155
* This creates an instance then calls the second-phase constructor
156
* without leaving the instance on the cleanup stack.
157
* @return new instance of Csymbian_ua_guiContainerView
159
Csymbian_ua_guiContainerView* Csymbian_ua_guiContainerView::NewL()
161
Csymbian_ua_guiContainerView* self = Csymbian_ua_guiContainerView::NewLC();
162
CleanupStack::Pop( self );
167
* Symbian two-phase constructor.
168
* This creates an instance, pushes it on the cleanup stack,
169
* then calls the second-phase constructor.
170
* @return new instance of Csymbian_ua_guiContainerView
172
Csymbian_ua_guiContainerView* Csymbian_ua_guiContainerView::NewLC()
174
Csymbian_ua_guiContainerView* self = new ( ELeave ) Csymbian_ua_guiContainerView();
175
CleanupStack::PushL( self );
182
* Second-phase constructor for view.
183
* Initialize contents from resource.
185
void Csymbian_ua_guiContainerView::ConstructL()
187
// [[[ begin generated region: do not modify [Generated Code]
188
BaseConstructL( R_SYMBIAN_UA_GUI_CONTAINER_SYMBIAN_UA_GUI_CONTAINER_VIEW );
189
// ]]] end generated region [Generated Code]
191
// add your own initialization code here
192
symbian_ua_info_cb_t cb;
193
Mem::FillZ(&cb, sizeof(cb));
195
cb.on_info = &on_info;
196
cb.on_incoming_call = &on_incoming_call;
197
cb.on_reg_state = &on_reg_state;
198
cb.on_unreg_state = &on_unreg_state;
199
cb.on_call_end = &on_call_end;
201
symbian_ua_set_info_callback(&cb);
206
* @return The UID for this view
208
TUid Csymbian_ua_guiContainerView::Id() const
210
return TUid::Uid( ESymbian_ua_guiContainerViewId );
214
* Handle a command for this view (override)
215
* @param aCommand command id to be handled
217
void Csymbian_ua_guiContainerView::HandleCommandL( TInt aCommand )
219
// [[[ begin generated region: do not modify [Generated Code]
220
TBool commandHandled = EFalse;
222
{ // code to dispatch to the AknView's menu and CBA commands is generated here
224
case ESymbian_ua_guiContainerViewControlPaneRightId:
225
commandHandled = CallSoftKeyPressedL( aCommand );
227
case ESymbian_ua_guiContainerViewSettingMenuItemCommand:
228
commandHandled = HandleSettingMenuItemSelectedL( aCommand );
235
if ( !commandHandled )
238
if ( aCommand == ESymbian_ua_guiContainerViewControlPaneRightId )
240
AppUi()->HandleCommandL( EEikCmdExit );
244
// ]]] end generated region [Generated Code]
249
* Handles user actions during activation of the view,
250
* such as initializing the content.
252
void Csymbian_ua_guiContainerView::DoActivateL(
253
const TVwsViewId& /*aPrevViewId*/,
254
TUid /*aCustomMessageId*/,
255
const TDesC8& /*aCustomMessage*/ )
257
// [[[ begin generated region: do not modify [Generated Contents]
260
CEikButtonGroupContainer* cba = AppUi()->Cba();
263
cba->MakeVisible( EFalse );
266
if ( iSymbian_ua_guiContainer == NULL )
268
iSymbian_ua_guiContainer = CSymbian_ua_guiContainer::NewL( ClientRect(), NULL, this );
269
iSymbian_ua_guiContainer->SetMopParent( this );
270
AppUi()->AddToStackL( *this, iSymbian_ua_guiContainer );
272
// ]]] end generated region [Generated Contents]
274
cba = CEikButtonGroupContainer::Current();
276
if (symbian_ua_anycall())
277
cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStHangUp);
279
cba->SetCommandL(ESymbian_ua_guiContainerViewControlPaneRightId, KStCall);
286
void Csymbian_ua_guiContainerView::DoDeactivate()
288
// [[[ begin generated region: do not modify [Generated Contents]
291
CEikButtonGroupContainer* cba = AppUi()->Cba();
294
cba->MakeVisible( ETrue );
298
if ( iSymbian_ua_guiContainer != NULL )
300
AppUi()->RemoveFromViewStack( *this, iSymbian_ua_guiContainer );
301
delete iSymbian_ua_guiContainer;
302
iSymbian_ua_guiContainer = NULL;
304
// ]]] end generated region [Generated Contents]
308
// [[[ begin generated function: do not modify
309
void Csymbian_ua_guiContainerView::SetupStatusPaneL()
311
// reset the context pane
312
TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
313
CEikStatusPaneBase::TPaneCapabilities subPaneContext =
314
StatusPane()->PaneCapabilities( contextPaneUid );
315
if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
317
CAknContextPane* context = static_cast< CAknContextPane* > (
318
StatusPane()->ControlL( contextPaneUid ) );
319
context->SetPictureToDefaultL();
322
// setup the title pane
323
TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
324
CEikStatusPaneBase::TPaneCapabilities subPaneTitle =
325
StatusPane()->PaneCapabilities( titlePaneUid );
326
if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
328
CAknTitlePane* title = static_cast< CAknTitlePane* >(
329
StatusPane()->ControlL( titlePaneUid ) );
330
TResourceReader reader;
331
iEikonEnv->CreateResourceReaderLC( reader, R_SYMBIAN_UA_GUI_CONTAINER_TITLE_RESOURCE );
332
title->SetFromResourceL( reader );
333
CleanupStack::PopAndDestroy(); // reader internal state
337
// ]]] end generated function
339
// [[[ begin generated function: do not modify
340
void Csymbian_ua_guiContainerView::CleanupStatusPane()
343
// ]]] end generated function
346
* Handle status pane size change for this view (override)
348
void Csymbian_ua_guiContainerView::HandleStatusPaneSizeChange()
350
CAknView::HandleStatusPaneSizeChange();
352
// this may fail, but we're not able to propagate exceptions here
354
TRAP( result, SetupStatusPaneL() );
358
* Handle the rightSoftKeyPressed event.
359
* @return ETrue if the command was handled, EFalse if not
361
TBool Csymbian_ua_guiContainerView::CallSoftKeyPressedL( TInt aCommand )
363
CEikEdwin *obj_url = (CEikEdwin*) iSymbian_ua_guiContainer->ComponentControl(iSymbian_ua_guiContainer->EEd_url);
364
CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
366
if (symbian_ua_anycall()) {
367
symbian_ua_endcall();
371
PutMessage(_L("Making call..."));
373
cba->SetCommandL(aCommand, KStHangUp);
379
TPtr8 aUrl(url, 256);
381
HBufC *buf = obj_url->GetTextInHBufL();
382
CnvUtfConverter::ConvertFromUnicodeToUtf8(aUrl, *buf);
385
if (symbian_ua_makecall((char *)aUrl.PtrZ()) != 0) {
386
PutMessage(_L("Making call failed!"));
388
cba->SetCommandL(aCommand, KStCall);
397
* Handle the selected event.
398
* @param aCommand the command id invoked
399
* @return ETrue if the command was handled, EFalse if not
401
TBool Csymbian_ua_guiContainerView::HandleSettingMenuItemSelectedL( TInt aCommand )
403
AppUi()->ActivateLocalViewL(TUid::Uid(ESymbian_ua_guiSettingItemListViewId));
407
// [[[ begin generated function: do not modify
409
* Show the popup note for note_error
410
* @param aOverrideText optional override text
412
void Csymbian_ua_guiContainerView::RunNote_errorL( const TDesC* aOverrideText )
414
CAknErrorNote* note = new ( ELeave ) CAknErrorNote();
415
if ( aOverrideText == NULL )
417
HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_ERROR );
418
note->ExecuteLD( *noteText );
419
CleanupStack::PopAndDestroy( noteText );
423
note->ExecuteLD( *aOverrideText );
426
// ]]] end generated function
428
// [[[ begin generated function: do not modify
430
* Show the popup note for note_info
431
* @param aOverrideText optional override text
433
void Csymbian_ua_guiContainerView::RunNote_infoL( const TDesC* aOverrideText )
435
CAknInformationNote* note = new ( ELeave ) CAknInformationNote();
436
if ( aOverrideText == NULL )
438
HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_INFO );
439
note->ExecuteLD( *noteText );
440
CleanupStack::PopAndDestroy( noteText );
444
note->ExecuteLD( *aOverrideText );
447
// ]]] end generated function
449
// [[[ begin generated function: do not modify
451
* Show the popup note for note_warning
452
* @param aOverrideText optional override text
454
void Csymbian_ua_guiContainerView::RunNote_warningL( const TDesC* aOverrideText )
456
CAknWarningNote* note = new ( ELeave ) CAknWarningNote();
457
if ( aOverrideText == NULL )
459
HBufC* noteText = StringLoader::LoadLC( R_SYMBIAN_UA_GUI_CONTAINER_NOTE_WARNING );
460
note->ExecuteLD( *noteText );
461
CleanupStack::PopAndDestroy( noteText );
465
note->ExecuteLD( *aOverrideText );
468
// ]]] end generated function
470
// [[[ begin generated function: do not modify
472
* Show the popup dialog for qry_accept_call
473
* @param aOverrideText optional override text
474
* @return EAknSoftkeyYes (left soft key id) or 0
476
TInt Csymbian_ua_guiContainerView::RunQry_accept_callL( const TDesC* aOverrideText )
479
CAknQueryDialog* queryDialog = CAknQueryDialog::NewL();
481
if ( aOverrideText != NULL )
483
queryDialog->SetPromptL( *aOverrideText );
485
return queryDialog->ExecuteLD( R_SYMBIAN_UA_GUI_CONTAINER_QRY_ACCEPT_CALL );
487
// ]]] end generated function