📄 esimappui.cpp
字号:
/*
============================================================================
Name : CESIMAppUi from ESIMAppui.cpp
Author : hagu
Date : 2007/5/30
Description : CESIMAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include "ESIMAppUi.h"
#include <ESIM.rsg>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <akntitle.h>
#include <avkon.hrh>
#include <utf.h>
#include <documenthandler.h>// for launching
#include <aknmessagequerydialog.h>
#include "S32FILE.H"
#include "ESIM.hrh"
#include "ESIMDocument.h"
#include "ESIMUserItem.h"
#include "ESIMUserItemForm.h"
#include "ESIMUserView.h"
#include "ESIMGroupItem.h"
#include "ESIMGroupView.h"
#include "ESIMItemEngine.h"
#include "ESIMGroupUserView.h"
#include <SIPEngine.h>
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CESIMAppUi::ConstructL()
//
// ----------------------------------------------------------
//
void CESIMAppUi::ConstructL()
{
BaseConstructL(EAknEnableSkin);
// Show tabs for main views from resources
CEikStatusPane* sp = StatusPane();
// Fetch pointer to the default navi pane control
iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(
TUid::Uid(EEikStatusPaneUidNavi));
// Tabgroup has been read from resource and it were pushed to the navi pane.
// Get pointer to the navigation decorator with the ResourceDecorator() function.
// Application owns the decorator and it has responsibility to delete the object.
iDecoratedTabGroup = iNaviPane->ResourceDecorator();
if (iDecoratedTabGroup)
{
iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
iTabGroup->SetObserver( this );
}
iItemEngine = static_cast<CESIMDocument*>(Document())->GetItemEngine();
//好友列表视图
CESIMUserView* userView = new (ELeave) CESIMUserView(iItemEngine);
CleanupStack::PushL( userView );
userView->ConstructL();
AddViewL( userView );
CleanupStack::Pop();
//群组列表视图
CESIMGroupView* groupView = new (ELeave) CESIMGroupView(iItemEngine);
CleanupStack::PushL( groupView );
groupView->ConstructL();
AddViewL( groupView );
CleanupStack::Pop();
//群组中好友列表视图
CESIMGroupUserView* groupUserView = new (ELeave) CESIMGroupUserView(iItemEngine);
CleanupStack::PushL( groupUserView );
groupUserView->ConstructL();
AddViewL( groupUserView );
CleanupStack::Pop();
SetDefaultViewL(*userView);
iSIPEngine = CSIPEngine::NewL(this);
iSIPEngine->StartL(IPPROTO_UDP, 5060, "192.168.186.107", 5060);
}
// ----------------------------------------------------
// CESIMAppUi::~CESIMAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CESIMAppUi::~CESIMAppUi()
{
delete iDecoratedTabGroup;
delete iSIPEngine;
}
// ------------------------------------------------------------------------------
// CESIMAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
// This function is called by the EIKON framework just before it displays
// a menu pane. Its default implementation is empty, and by overriding it,
// the application can set the state of menu items dynamically according
// to the state of application data.
// ------------------------------------------------------------------------------
//
void CESIMAppUi::DynInitMenuPaneL(
TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}
// ----------------------------------------------------
// CESIMAppUi::HandleKeyEventL(
// const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// takes care of key event handling
// ----------------------------------------------------
//
TKeyResponse CESIMAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
{
if ( iTabGroup == NULL )
{
return EKeyWasNotConsumed;
}
if ( aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow )
{
return iTabGroup->OfferKeyEventL( aKeyEvent, aType );
}
else
{
return EKeyWasNotConsumed;
}
}
// ----------------------------------------------------
// CESIMAppUi::HandleCommandL(TInt aCommand)
// takes care of command handling
// ----------------------------------------------------
//
void CESIMAppUi::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyExit:
case EEikCmdExit:
{
if (my_QueryDialog(_L("Quit?")) != 0)
{
return;
}
Exit();
break;
}
case EESIMCmdActiveUserView:
{
iTabGroup->SetActiveTabByIndex(0);
HBufC* titleText = StringLoader::LoadLC(R_USER_TITLE_TEXT);
SetViewTitle(titleText);
CleanupStack::PopAndDestroy(titleText);
//KUserViewId = {4}
ActivateLocalViewL(KUserViewId);
break;
}
case EESIMCmdActiveGroupView:
{
iTabGroup->SetActiveTabByIndex(1);
HBufC* titleText = StringLoader::LoadLC(R_GROUP_TITLE_TEXT);
SetViewTitle(titleText);
CleanupStack::PopAndDestroy(titleText);
//KGroupViewId = {3}
ActivateLocalViewL(KGroupViewId);
break;
}
case EESIMCmdActiveGroupUserView:
{
HBufC* titleText = StringLoader::LoadLC(R_GROUPUSER_TITLE_TEXT);
SetViewTitle(titleText);
CleanupStack::PopAndDestroy(titleText);
//KGroupUserViewId = {1}
ActivateLocalViewL(KGroupUserViewId);
break;
}
default:
break;
}
}
// ----------------------------------------------------
// CESIMAppUi::TabChangedL(TInt aIndex)
// This method gets called when CAknTabGroup active
// tab has changed.
// ----------------------------------------------------
//
void CESIMAppUi::TabChangedL(TInt aIndex)
{
if (aIndex == 0)
HandleCommandL(EESIMCmdActiveUserView);
else if(aIndex == 1)
HandleCommandL(EESIMCmdActiveGroupView);
}
void CESIMAppUi::ShowConformationNote(const TDesC& aPrompt)
{
//Show confirmation note
CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote();
note->ExecuteLD(aPrompt);
}
CESIMItemEngine* CESIMAppUi::GetItemEngine()
{
return iItemEngine;
}
void CESIMAppUi::SetViewTitle(HBufC* aTitleText)
{
TUid conversationTitlePaneUid;
conversationTitlePaneUid.iUid = EEikStatusPaneUidTitle;
CEikStatusPane* statusPane = StatusPane();
CEikStatusPaneBase::TPaneCapabilities subPane =
statusPane->PaneCapabilities(conversationTitlePaneUid);
if(subPane.IsPresent() && subPane.IsAppOwned())
{
CAknTitlePane* titlePane = (CAknTitlePane*)statusPane->ControlL(conversationTitlePaneUid);
titlePane->SetTextL(*aTitleText);
}
}
TInt CESIMAppUi::GetCurrentGroupIndex()
{
return iItemEngine->GetCurrentGrouuIndex();
}
TInt CESIMAppUi::GetCurrentUserIndex()
{
return iItemEngine->GetCurrentUserIndex();
}
TInt CESIMAppUi::my_QueryDialog(const TDesC& aTitle)
{
CAknQueryDialog* dlg = CAknQueryDialog::NewL( );
if ( dlg->ExecuteLD(R_QUERY_DIALOG, aTitle))
{
return 0;
}
return -1;
}
void CESIMAppUi::my_MessageDialog(const TDesC& aMessage, const TDesC& aTitle)
{
TBuf<300> pMsg;
pMsg.Append(aMessage);
TBuf<30> pTitle;
pTitle.Append(aTitle);
CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(pMsg);
dlg->PrepareLC(R_MESSAGE_QUERY);
dlg->QueryHeading()->SetTextL(pTitle);
dlg->RunLD();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -