📄 esimuserview.cpp
字号:
/*
============================================================================
Name : ESIMUserView.cpp
Author :
Version :
Copyright : Your copyright notice
Description : ESIMUserView.cpp - source file
============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <ESIM.rsg>
#include "ESIM.hrh"
#include "ESIMUserView.h"
#include "ESIMUserContainer.h"
#include "ESIMGroupItem.h"
#include "ESIMUserItem.h"
#include "ESIMItemEngine.h"
#include "ESIMDocument.h"
#include "SIPEngine.h"
#include <eikmenup.h> //for CEikMenuPane
#include <barsread.h>
#include <aknnavi.h>
#include <aknpopup.h>
#include <stringloader.h> // StringLoader
#include <aknlists.h>
#include <aknquerydialog.h>
#include <utf.h>
#include "ESIMAppui.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CESIMUserView::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CESIMUserView::ConstructL()
{
BaseConstructL( R_ESIM_USER_VIEW );
}
// ---------------------------------------------------------
// CESIMUserView::~ESIMUserView()
// destructor
// ---------------------------------------------------------
//
CESIMUserView::~CESIMUserView()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
}
// ---------------------------------------------------------
// TUid CESIMUserView::Id()
//
// ---------------------------------------------------------
//
TUid CESIMUserView::Id() const
{
return KUserViewId;
}
// ---------------------------------------------------------
// CESIMUserView::HandleCommandL(TInt aCommand)
// takes care of view command handling
// ---------------------------------------------------------
//
void CESIMUserView::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyBack:
{
AppUi()->HandleCommandL(EEikCmdExit);
break;
}
case EESIMUserCmdEdit:
{
iEngine->EditUserFormL((iContainer->ListBox())->CurrentItemIndex());
iContainer->RefreshListL();
break;
}
case EESIMUserCmdNew:
{
iEngine->NewUserFormL();
CEikDocument* doc =
static_cast< CEikAppUi* >( CEikonEnv::Static()->AppUi() )->Document();
static_cast< CESIMDocument* >( doc )->SaveL();
iContainer->RefreshListL();
break;
}
case EESIMUserCmdDelete:
{
iContainer->DeleteSelectedL();
iContainer->RefreshListL();
break;
}
case EESIMCmdActiveConversationView:
{
break;
}
case EESIMCmdSendTimedMessage:
{
break;
}
case EESIMCmdSendAnonymousMessage:
{
break;
}
case EESIMCmdReceiveMessage:
{
ReceiveMessage(_L("HellWorld!"));
break;
}
case EESIMCmdSendMessage:
{
TInt KMaxMessageLength = 60;
TInt KMaxMessageSizeDesc16 = KMaxMessageLength * 2;
HBufC* iMessage;
iMessage = HBufC::NewL(KMaxMessageLength);
TPtr message = iMessage->Des();
HBufC* titleBuf = StringLoader::LoadLC(R_CHAT_TITLE);
CAknTextQueryDialog* messageDialog = new (ELeave) CAknTextQueryDialog(message,
*titleBuf, CAknTextQueryDialog::ENoTone);
CleanupStack::PopAndDestroy(titleBuf);
messageDialog->SetMaxLength(KMaxMessageLength);
if (messageDialog->ExecuteLD(R_ESIM_CHAT_MESSAGE_DIALOG))
{
CAknViewAppUi* aAknViewAppUi = AppUi();
CESIMAppUi* aESIMAppUi = reinterpret_cast<CESIMAppUi*>(aAknViewAppUi);
TBuf8<50> tmp;
TBuf8<100> to;
CnvUtfConverter::ConvertFromUnicodeToUtf8(tmp,
(iEngine->UserItem(iContainer->ListBox()->CurrentItemIndex())->SipAddress())->Des());
to.Format(_L8("sip:%s"), tmp.PtrZ());
TBuf8<50> from;
from.Format(_L8("sip:%s"), aESIMAppUi->iLocalAddress.Ptr());
TBuf8<100> msg;
CnvUtfConverter::ConvertFromUnicodeToUtf8(msg, message);
aESIMAppUi->iSIPEngine->sip_message((char*)msg.PtrZ(), (char*)to.PtrZ(),
(char*)from.PtrZ());
}
delete iMessage;
iMessage = NULL;
break;
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
// ---------------------------------------------------------
// CESIMUserView::HandleClientRectChange()
// ---------------------------------------------------------
//
void CESIMUserView::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------
// CESIMUserView::DoActivateL(...)
//
// ---------------------------------------------------------
//
void CESIMUserView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
if (!iContainer)
{
iContainer = new (ELeave) CESIMUserContainer(iEngine);
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect(),this);
AppUi()->AddToStackL( *this, iContainer );
}
// iContainer->Start(); // Issue the 2sec delay request
}
// ---------------------------------------------------------
// CESIMUserView::DoDeactivate()
//
// ---------------------------------------------------------
//
void CESIMUserView::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
void CESIMUserView::DynInitMenuPaneL(TInt aResourceId,
CEikMenuPane* aMenuPane)
{
if (aResourceId == R_ESIM_USER_VIEW_MENU)
{
aMenuPane->SetItemDimmed(EESIMUserCmdEdit,iContainer->IsItemOnListBox());
aMenuPane->SetItemDimmed(EESIMUserCmdDelete,iContainer->IsItemOnListBox());
aMenuPane->SetItemDimmed(EESIMUserCmdMessage,iContainer->IsItemOnListBox());
aMenuPane->SetItemDimmed(EESIMCmdReceiveMessage,iContainer->IsItemOnListBox());
// aMenuPane->SetItemDimmed(EESIMCmdSendFile,iContainer->IsItemOnListBox());
}
}
/**
* Loads the levels for aSavedGameMenuListArray.
* This method merely creates some list items dynamically, and adds them
* to the array. In a real-world example, it is likely that the
* items would be read from a file
* @param aSavedGameMenuListArray The array where the saved game levels will be stored
*/
//void CESIMUserView::AddContactToGroup(TDesC& aSavedGameName)
// void CESIMUserView::AddContactToGroup()
// {
//
// // First phase construction of menu list
// CAknSinglePopupMenuStyleListBox* savedGameMenuList =
// new (ELeave) CAknSinglePopupMenuStyleListBox;
// CleanupStack::PushL(savedGameMenuList);
//
// // Create a popuplist to show the menu list in
// CAknPopupList* popupList = CAknPopupList::NewL(
// savedGameMenuList,
// R_AVKON_SOFTKEYS_OK_BACK);
//
// CleanupStack::PushL(popupList);
//
// // Second phase construction of menulist
// savedGameMenuList->ConstructL(popupList,EAknListBoxMenuList);
// // Set up scroll bars
// SetupScrollBarsL (*savedGameMenuList);
//
// // Set up menu items
// CTextListBoxModel* model = savedGameMenuList->Model(); // not taking ownership
// model->SetOwnershipType (ELbmOwnsItemArray);
// CDesCArray* savedGameMenuListArray = STATIC_CAST(CDesCArray*, model->ItemTextArray());
//
// //CDesCArray *groups = iEngine->GetContactGroupsL();
// _LIT (KStringHeader, "%S");
// TBuf <16> aString;
// for (TInt i = 0; i< iEngine->GroupItemCount(); i++)
// {
// TPtrC ptr = ((iEngine->GroupItem(i))->Name())->Des();
// aString.Format(KStringHeader(), &ptr);
// savedGameMenuListArray->AppendL (aString);
// }
//
// // Set title
// HBufC* title;
// title = StringLoader::LoadLC(R_SAVED_GAME_MENU_LIST_TITLE); // Pushes title onto the Cleanup Stack.
// popupList->SetTitleL(*title);
// CleanupStack::PopAndDestroy(title);
//
// // Show the menu in the popup list
// TInt popupOk = popupList->ExecuteLD();
//
// CleanupStack::Pop(popupList);
//
// // if the user selected a level to play, play the game at that level
// if (popupOk)
// {
// //TDesC level = (*savedGameMenuListArray)[savedGameMenuList->CurrentItemIndex()];
// TInt groupIndex = savedGameMenuList->CurrentItemIndex();
// //TDesC level = (*savedGameMenuListArray)[index];
//
//
// /*iEngine->GetSelectedContactL(iContainer->ListBox());
// iEngine->GetSelectedContactGroupL(groupIndex);*/
//
// iEngine->AddUserToGroupL(iContainer->ListBox()->CurrentItemIndex(),groupIndex);
//
// CleanupStack::PopAndDestroy(savedGameMenuList);
// //PlayGame (aSavedGameName, level);
// }
// // otherwise return to the saved game list
// else
// CleanupStack::PopAndDestroy(savedGameMenuList);
// }
/**
* Creates vertical scrollbars for the list, which appear automatically when required.
*
*/
void CESIMUserView::SetupScrollBarsL(CEikListBox& aListBox)
{
aListBox.CreateScrollBarFrameL(ETrue);
aListBox.ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
}
/**
* Display the message received from remote device.
* @param aMessage the message received
* @return none
*/
void CESIMUserView::ReceiveMessage(const TDesC& aMessage)
{
}
void CESIMUserView::SendFile(const TDesC& aMessage)
{
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -