⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmsexampleappui.cpp

📁 Symbian c++ 的彩信发送接收实例
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CFileListAppUi from FileListAppUi.cpp
*  Part of  : FileList
*  Created  : 04.11.2006 by Forum Nokia
*  Version  : 2.0
*  Copyright: Nokia Corporation
* ============================================================================
*/

#include <avkon.hrh>
#include <eikmenup.h>
#include <aknquerydialog.h>
#include <MMSExample.rsg>

#include "MMSExampleAppUi.h"
#include "MMSExampleContainer.h" 
#include "MMSExample.hrh"
#include "MmsEngine.h"

#define KEnableSkinFlag 	 0x1000

#define KMessagingUID3	     0x100058C5		//messaging uid
#define KMessagingListViewID 0x02
#define KInboxUID			 0x1002			//inbox uid
#define KSentUID  		 	 0x1005			//sentbox uid

/*
-----------------------------------------------------------------------------
  CMMSExampleAppUi::ConstructL()                          
  2nd phase constructor
-----------------------------------------------------------------------------
*/
void CMMSExampleAppUi::ConstructL()
    {
	BaseConstructL( EAknEnableSkin );

    iAppContainer = new (ELeave) CMMSExampleContainer;
    iAppContainer->SetMopParent(this);
    iAppContainer->ConstructL(ClientRect());

    AddToStackL( iAppContainer );

	iMmsEngine = CMmsEngine::NewL( *this );
    }

// ----------------------------------------------------
// CMMSExampleAppUi::~CMMSExampleAppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CMMSExampleAppUi::~CMMSExampleAppUi()
    {
    if (iAppContainer)
        {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
        iAppContainer = NULL;
        }

	delete iMmsEngine;
   	}

/*
-----------------------------------------------------------------------------
    CMMSExampleAppUi::HandleCommandL(TInt aCommand)
    Handle the menu commands
-----------------------------------------------------------------------------
*/
void CMMSExampleAppUi::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
        {
		case EMMSExampleCmdSend:
			CmdSendL();
			break;

		case EMMSExampleCmdOpenInbox:
			CmdOpenMessagingL();
			break;

		case EMMSExampleCmdOpenSent:
			CmdOpenMessagingL();
			break;

		case EAknSoftkeyBack:
		case EEikCmdExit:
		case EClose:
    		CmdExit();
			break;
		default:
			break;
        }
    }

/*
-----------------------------------------------------------------------------
    CMMSExampleAppUi::CmdSendL()
   	Initialize Communications and then send the multimedia message.
-----------------------------------------------------------------------------
*/
_LIT( KText, "Hello, the world!" );

void CMMSExampleAppUi::CmdSendL()
    {
	TBuf<EMaxTelephoneNumberLength> recipient;

	CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(
		recipient, CAknQueryDialog::ENoTone );

	dlg->SetMaxLength( EMaxTelephoneNumberLength );

	TBool answer( dlg->ExecuteLD( R_TEL_NUM_QUERY ) );

	if ( answer )
		{
		if ( iMmsEngine )
			{
			iMmsEngine->SendToL( recipient, KText );
			}
		}
    }

/*
-----------------------------------------------------------------------------
    CMMSExampleAppUi::CmdOpenMessagingL()
    Opening the S60 messaging application.
-----------------------------------------------------------------------------
*/	
void CMMSExampleAppUi::CmdOpenMessagingL()
    {
    TVwsViewId id = TVwsViewId( TUid::Uid(KMessagingUID3),TUid::Uid(KMessagingListViewID) ); 
	_LIT8(KEmpty, "");
	#ifdef __WINS__ //Emulator used
		ActivateViewL( id, TUid::Uid( KSentUID ),KEmpty);
	#else //Device used
		ActivateViewL( id, TUid::Uid( KInboxUID ),KEmpty);
	#endif   
    }

/*
------------------------------------------------------------------------------
  	CMMSExampleAppUi::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 CMMSExampleAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
    {
    if (aResourceId == R_MMSEXAMPLE_OPTIONS_MENU)
    	{
		#ifdef __WINS__
		aMenuPane->SetItemDimmed(EMMSExampleCmdOpenInbox, ETrue);
		#else
		aMenuPane->SetItemDimmed(EMMSExampleCmdOpenSent, ETrue);
		#endif
    	}
    }
    
/*
---------------------------------------------------------
 	CMMSExampleAppUi::HandleStatusPaneSizeChange()
 	Called by framework when resource is changed.
---------------------------------------------------------
*/
void CMMSExampleAppUi::HandleStatusPaneSizeChange()
	{
	CAknAppUi::HandleStatusPaneSizeChange(); //call to upper class

	if(iAppContainer)
		iAppContainer->SetRect( ClientRect() );
	}

/*
---------------------------------------------------------
	CMMSExampleAppUi::CmdExit()
	Exit program.
---------------------------------------------------------
*/
void CMMSExampleAppUi::CmdExit()
	{
	PrepareToExit();
    Exit();	
	}

void CMMSExampleAppUi::HandleStatusChange(MMsvObserver::TStatus /*aStatus*/ )
    {
    }

void CMMSExampleAppUi::HandleError(MMsvObserver::TError /*aError*/)
    {
    }

void CMMSExampleAppUi::HandleReceivedMessage(const TDesC& /*aMessageText*/)
    {
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -