📄 cmmssappui.cpp
字号:
/* Copyright (c) 2004, Nokia. All rights reserved */
// INCLUDE FILES
#include <avkon.hrh>
#include <eikapp.h>
#include <eikenv.h>
#include <eikmenup.h>
#include <eikedwin.h>
#include <apparc.h>
#include <stringloader.h>
#include <aknnotewrappers.h>
#include <mmsconst.h>
#include <mmssend.rsg>
#include "mmssend.pan"
#include "mmssend.hrh"
#include "mmssendEnum.rh"
#include "CMmssAppUi.h"
#include "CMmssSendDialog.h"
#include "CMmssSendHandler.h"
#include "CMmssReceiveHandler.h"
// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------------------------
// CMmssAppUi::ConstructL()
// Creates application dialog, MMS sendhandler and
// MMS receivehandler.
// ----------------------------------------------------------------------------
//
void CMmssAppUi::ConstructL()
{
BaseConstructL();
// Create dialog
iSendDialog = new ( ELeave ) CMmssSendDialog;
iSendDialog->SetMopParent( this );
iSendDialog->ExecuteLD( R_MMSSEND_DIALOG );
AddToStackL( iSendDialog );
//Create MMS send handler
iSendHandler = CMmssSendHandler::NewL( *this );
//Create MMS receive handler
iReceiveHandler = CMmssReceiveHandler::NewL( *this );
}
// ----------------------------------------------------------------------------
// CMmssAppUi::CMmssAppUi()
// Constructror
// ----------------------------------------------------------------------------
//
CMmssAppUi::CMmssAppUi()
{
// No implementation required
}
// ----------------------------------------------------------------------------
// CMmssAppUi::~CMmssAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------------------------------
//
CMmssAppUi::~CMmssAppUi()
{
if ( iSendDialog )
{
RemoveFromStack( iSendDialog );
}
delete iSendDialog;
delete iSendHandler;
delete iReceiveHandler;
}
// ----------------------------------------------------------------------------
// CMmssAppUi::DynInitMenuPaneL()
// 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 CMmssAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
{
if ( aResourceId == R_MMSSEND_MENU )
{
//Wait for server session opening
if( iSendHandler->IsIdle() )
{
aMenuPane->SetItemDimmed( EMmsAsyncSend, EFalse );
}
else
{
aMenuPane->SetItemDimmed( EMmsAsyncSend, EFalse );
}
}
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleKeyEventL()
// Takes care of key event handling
// ----------------------------------------------------------------------------
//
TKeyResponse CMmssAppUi::HandleKeyEventL(
const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleCommandL()
// Takes care of command handling
// ----------------------------------------------------------------------------
//
void CMmssAppUi::HandleCommandL( TInt aCommand )
{
switch( aCommand )
{
case EAknCmdExit:
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case EMmsAsyncSend:
{
TBuf<EMaxRecipientTextLength> msgRecipient(0);
TBuf<EMaxSubjectTextLength> msgSubject(0);
TFileName appFullPath(0);
// On emulator, the sound files used by application are
// deployed onto Z: drive
// On real phone, application can be installed to the
// memory card (non-"C/Z:" drive), this part of code evaluates
// current application path:
// find the instance of EikonEnv
CEikonEnv& eikEnv = *CEikonEnv::Static();
// derive the instance of EikonAppUi
CEikAppUi& eikAppUi = *( eikEnv.EikAppUi() );
// fetch the application full filename
appFullPath = (eikAppUi.Application())->AppFullName();
// Get the message recipient and subject details from the dialog
static_cast<CEikEdwin*>(
( iSendDialog->Control( EMmsRecipientEditor ) ) )->GetText( msgRecipient );
static_cast<CEikEdwin*>(
( iSendDialog->Control( EMmsSubjectEditor ) ) )->GetText( msgSubject );
// Our message should at least include the recipient address
// (gsm or email).
// Note: if Gsm then it could be with or without country code
// (e.g +358) ref. for Finland
// If email used it would be like "Mickey.Mouse@duckburg.com"
// The maximu address size and subject is limited to 30 characters.
if ( msgRecipient.Length() == 0 )
{
HBufC16* msgRecRequired =
StringLoader::LoadLC( R_MMSSEND_MSG_RECIPIENT_REQUIRED );
CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote;
errorNote->ExecuteLD( msgRecRequired->Des() );
CleanupStack::PopAndDestroy( msgRecRequired );
return;
}
// Now send it asynchronously.
// We'll get progress updates via the observer
static_cast<CMmssSendHandler*>
( iSendHandler )->SendToL( msgRecipient,
msgSubject,
appFullPath );
break;
}
default:
User::Panic( KMms, EMmsBasicUi );
break;
}
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleStatusChange()
// Takes care of status change handling
// ----------------------------------------------------------------------------
//
void CMmssAppUi::HandleStatusChange( MMsvObserver::TStatus aStatus )
{
CEikonEnv::Static()->InfoMsgCancel();
switch ( aStatus )
{
case ECreated:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_MSG_CREATED);
break;
case EMovedToDrafts:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_MSG_MOVED_DRAFTS );
break;
case EMovedToOutBox:
{
CEikonEnv::Static()->InfoMsg( R_MMSSEND_MSG_MOVED_OUTBOX );
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_MSG_MOVED_TOOUTBOX );
CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( aText1->Des() );
CleanupStack::PopAndDestroy( aText1 );
break;
}
case EScheduledForSend:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_MSG_SCHEDULED );
break;
case ESent:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_MSG_SENT );
break;
case EDeleted:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_MSG_DELETED );
break;
default:
User::Panic( KMms, EMmsStatusCode );
break;
}
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleServerStatusChange()
// Takes care of server status change handling
// ----------------------------------------------------------------------------
//
void CMmssAppUi::HandleServerStatusChange( MMsvObserver::TServerStatus aStatus )
{
CEikonEnv::Static()->InfoMsgCancel();
switch ( aStatus )
{
case EServerOpen:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_SERVER_SESSION_OPENED );
break;
case EServerClose:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_SERVER_SESSION_CLOSED );
break;
case EServerTerminate:
CEikonEnv::Static()->InfoMsg( R_MMSSEND_SERVER_SESSION_TERMINATED );
break;
default:
User::Panic( KMms, EMmsServerStatusCode );
break;
}
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleErrorL()
// Takes care of general message error handling
// ----------------------------------------------------------------------------
//
void CMmssAppUi::HandleErrorL( MMsvObserver::TError aError )
{
switch ( aError )
{
case EScheduleFailed:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_MSG_INFO );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_MSG_SCHEDULE_FAILED );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 ); // aText1, aText2
break;
}
case EDeleteFailed:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_MSG_INFO );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_MSG_DELETE_FAILED );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 ); // aText1, aText2
break;
}
case ESendFailed:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_MSG_INFO );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_MSG_SENT_FAILED );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 ); // aText1, aText2
break;
}
case ENoServiceCentre:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_MSG_INFO );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_NO_SERVICE_CENTRE );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 ); // aText1, aText2
break;
}
case EFatalServerError:
{
User::Panic( KMms, EMmsFatalServerError );
break;
}
default:
{
User::Panic( KMms, EMmsErrorCode );
break;
}
}
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleAttachmentErrorL()
// Takes care of attachment error handling
// ----------------------------------------------------------------------------
//
void CMmssAppUi::HandleAttachmentErrorL( MMsvObserver::TAttachmentError aError )
{
switch ( aError )
{
case EConnectionFailed:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_RFS_CONNECTION );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_RFS_CONNECTION_FAILED );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 );
break;
}
case EFileNameWrong:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_RFS_FILEPATH );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_RFS_FILEPATH_FAILED );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 );
break;
}
case EFileLoadFailed:
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_RFS_FILELOAD );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_RFS_FILELOAD_FAILED );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 );
break;
}
default:
{
User::Panic( KMms, EMmsAttachmentErrorCode );
break;
}
}
}
// ----------------------------------------------------------------------------
// CMmssAppUi::HandleReceivedMessageL()
// Takes care of handling of received messages
// ----------------------------------------------------------------------------
//
void CMmssAppUi::HandleReceivedMessageL()
{
HBufC16* aText1 = StringLoader::LoadLC( R_MMSSEND_MSG_RECEIVED_NOTE );
HBufC16* aText2 = StringLoader::LoadLC( R_MMSSEND_MSG_TYPE_MMS );
CEikonEnv::Static()->InfoWinL( aText1->Des(), aText2->Des() );
CleanupStack::PopAndDestroy( 2 ); // aText1, aText2
}
// ----------------------------------------------------------------------------
// CMmssAppUi::ExitFromProgram()
// A major error has occurred, exit from program
// ----------------------------------------------------------------------------
//
void CMmssAppUi::ExitFromProgram()
{
User::Exit( 0 );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -