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

📄 ccontappui.cpp

📁 基于symbian OS的IP前缀添加器.可以在通话前为电话加一个IP的功能.
💻 CPP
字号:
/* Copyright (c) 2003, Nokia. All rights reserved */

// INCLUDE FILES

#include <contacts.rsg>
#include <avkon.hrh>
#include <eikmenup.h>
#include <eikmenub.h>
#include <akntitle.h>
#include <stringloader.h>

#include "CContAppUi.h"
#include "CContContainer.h"
#include "contacts.hrh"

#include "EikonEnvironment.h"



// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CContAppUi::ConstructL()
// Two phased constructor
// ----------------------------------------------------------
//
void CContAppUi::ConstructL()
    {
    BaseConstructL();

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

    }

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

   }

// ------------------------------------------------------------------------------
// CContAppUi::::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 CContAppUi::DynInitMenuPaneL(
    TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
    {

    }

// ----------------------------------------------------
// CContAppUi::HandleKeyEventL()
// Handles key events
// ----------------------------------------------------
//
TKeyResponse CContAppUi::HandleKeyEventL(
    const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
    {
    return EKeyWasNotConsumed;
    }

// ----------------------------------------------------
// CContAppUi::HandleCommandL()
// Handles user commands.
// ----------------------------------------------------
//
void CContAppUi::HandleCommandL( TInt aCommand )
    {
    switch ( aCommand )
        {
        // flowtrough
        case EAknSoftkeyExit:
        case EEikCmdExit:
            Exit();
            break;
        case EContactsNullIP:
            {

			// emulator does not support dialing,
			// display informative message and leave.
			#if defined(__WINS__)
					 // Load a string from the resource file.
				HBufC* textResource = StringLoader::LoadLC( R_DIAL_EMULATOR_USAGE_ERROR );
				NEikonEnvironment::MessageBox ( *textResource );
				// Pop HBuf from CleanUpStack and Destroy it.
				CleanupStack::PopAndDestroy( textResource );
				}
				break;
			#else

       			// go ahead with making call on real device.
				KDialPhoneNumber= iAppContainer.iNumber1;
				TRAPD( err, DialNumberL( KDialPhoneNumber ); );
				if ( err )
					{
					// Load a string from the resource file.
					HBufC* textResource = StringLoader::LoadLC( R_DIAL_DIALING_ERROR );
					NEikonEnvironment::MessageBox ( *textResource );
					// Pop HBuf from CleanUpStack and Destroy it.
					CleanupStack::PopAndDestroy( textResource );
					}
				}

				break;
			#endif      

		
		case EContactsCreateTemplate:
            iAppContainer->CreateContactTemplateL();
            break;

    	case EContactsCreateContact:
            iAppContainer->AddNewContactDlgL();
            break;
		case EContactsDeleteContact:
            iAppContainer->DeleteContactDlgL();
            break;
		
		case EContactsEditContact:
            iAppContainer->EditContactDlgL();
            break;
	
    
      case EContactsYdIP:
			 {
				#if defined(__WINS__)
					 // Load a string from the resource file.
				HBufC* textResource = StringLoader::LoadLC( R_DIAL_EMULATOR_USAGE_ERROR );
				NEikonEnvironment::MessageBox ( *textResource );
				// Pop HBuf from CleanUpStack and Destroy it.
				CleanupStack::PopAndDestroy( textResource );
				}
				break;
			#else

       			// go ahead with making call on real device.
				KDialPhoneNumber= iAppContainer.iNumber2;
				TRAPD( err, DialNumberL( KDialPhoneNumber ); );
				if ( err )
					{
					// Load a string from the resource file.
					HBufC* textResource = StringLoader::LoadLC( R_DIAL_DIALING_ERROR );
					NEikonEnvironment::MessageBox ( *textResource );
					// Pop HBuf from CleanUpStack and Destroy it.
					CleanupStack::PopAndDestroy( textResource );
					}
				}

				break;
			#endif      
		
		case EContactsLtIP:
			{
				#if defined(__WINS__)
					 // Load a string from the resource file.
				HBufC* textResource = StringLoader::LoadLC( R_DIAL_EMULATOR_USAGE_ERROR );
				NEikonEnvironment::MessageBox ( *textResource );
				// Pop HBuf from CleanUpStack and Destroy it.
				CleanupStack::PopAndDestroy( textResource );
				}
				break;
			#else

       			// go ahead with making call on real device.
				KDialPhoneNumber= iAppContainer.iNumber3;
				TRAPD( err, DialNumberL( KDialPhoneNumber ); );
				if ( err )
					{
					// Load a string from the resource file.
					HBufC* textResource = StringLoader::LoadLC( R_DIAL_DIALING_ERROR );
					NEikonEnvironment::MessageBox ( *textResource );
					// Pop HBuf from CleanUpStack and Destroy it.
					CleanupStack::PopAndDestroy( textResource );
					}
				}

				break;
			#endif      
		
		case EContactsSetIP:
			iAppContainer->ContactsSetIPL();
			break;
       
        default:
            break;
        
    }
}

// ----------------------------------------------------
// CContAppUi::UpdateTitleL()
// Update title
// ----------------------------------------------------
//
void CContAppUi::UpdateTitleL( TInt aResourceId )
    {
    HBufC* textResource = StringLoader::LoadLC( aResourceId );

    CAknTitlePane* titlePane = STATIC_CAST( CAknTitlePane*,
            StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );

    titlePane->SetTextL( textResource->Des());
    CleanupStack::PopAndDestroy( textResource );
    }

// -----------------------------------------------------------------------------
// CDialerAppUi::DialNumberL()
// Takes care of connection handling.
// -----------------------------------------------------------------------------
//
void CContAppUi::DialNumberL( const TDesC& aPhoneNumber )
    {
        //Create a connection to the tel server
        RTelServer server;
        CleanupClosePushL( server );
        User::LeaveIfError( server.Connect() );

        //Load in the phone device driver
        User::LeaveIfError( server.LoadPhoneModule( KTsyName ) );

        //Find the number of phones available from the tel server
        TInt numberPhones;
        User::LeaveIfError( server.EnumeratePhones( numberPhones ) );

        //Check there are available phones
        if ( numberPhones < 1 )
        {
            User::Leave( KErrNotFound );
        }

        //Get info about the first available phone
        RTelServer::TPhoneInfo info;
        User::LeaveIfError( server.GetPhoneInfo( 0, info ) );

        //Use this info to open a connection to the phone, the phone is
        //identified by its name
        RPhone phone;
        CleanupClosePushL( phone );
        User::LeaveIfError( phone.Open( server, info.iName ) );

        //Get info about the first line from the phone
        RPhone::TLineInfo lineInfo;
        User::LeaveIfError( phone.GetLineInfo( 0, lineInfo ) );

        //Use this to open a line
        RLine line;
        CleanupClosePushL( line );
        User::LeaveIfError( line.Open( phone, lineInfo.iName ) );

        //Open a new call on this line
        TBuf <100> newCallName;
        RCall call;
        CleanupClosePushL( call );
        User::LeaveIfError( call.OpenNewCall( line, newCallName ) );

        //newCallName will now contain the name of the call
        User::LeaveIfError( call.Dial( aPhoneNumber ) );

        //Close the phone, line and call connections and remove them
        //from the cleanup stack
        //NOTE: This does not hang up the call
        CleanupStack::PopAndDestroy( 3 );//phone, line, call

        //Unload the phone device driver
        User::LeaveIfError( server.UnloadPhoneModule( KTsyName ) );

        //Close the connection to the tel server and remove it
        //from the cleanup stack
        CleanupStack::PopAndDestroy( &server );
    }

// End of File

⌨️ 快捷键说明

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