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

📄 helloworldview.cpp

📁 该例子演示了如何在接受到来电时挂掉电话的功能
💻 CPP
字号:
// HelloWorldView.cpp
//
// ?Symbian Software Ltd 2005. All rights reserved.
//

#include <QikCommand.h>

#include "HelloWorldAppUi.h"
#include "HelloWorldView.h"
#include "HelloWorld.hrh"
#include "HelloWorldExternalInterface.h"
#include <HelloWorld.rsg>

#include <etel.h>

_LIT(KGsmModuleName, "erigsm.tsy");

/**
Creates and constructs the view.

@param aAppUi Reference to the AppUi
@return Pointer to a CHelloWorldView object
*/
CHelloWorldView* CHelloWorldView::NewLC(CQikAppUi& aAppUi)
	{
	CHelloWorldView* self = new (ELeave) CHelloWorldView(aAppUi);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

/**
Constructor for the view.
Passes the application UI reference to the construction of the super class.

KNullViewId should normally be passed as parent view for the applications 
default view. The parent view is the logical view that is normally activated 
when a go back command is issued. KNullViewId will activate the system 
default view. 

@param aAppUi Reference to the application UI
*/
CHelloWorldView::CHelloWorldView(CQikAppUi& aAppUi) 
	: CQikViewBase(aAppUi, KNullViewId)
	{
	}

/**
Destructor for the view
*/
CHelloWorldView::~CHelloWorldView()
	{
	}

/**
2nd stage construction of the view.
*/
void CHelloWorldView::ConstructL()
	{
	// Calls ConstructL that initialises the standard values. 
	// This should always be called in the concrete view implementations.
	BaseConstructL();
	}
	
/**
Inherited from CQikViewBase and called upon by the UI Framework. 
It creates the view from resource.
*/
void CHelloWorldView::ViewConstructL()
	{
	// Loads information about the UI configurations this view supports
	// together with definition of each view.	
	ViewConstructFromResourceL(R_HELLOWORLD_UI_CONFIGURATIONS);
	}

/**
Returns the view Id

@return Returns the Uid of the view
*/
TVwsViewId CHelloWorldView::ViewId()const
	{
	return TVwsViewId(KUidHelloWorldApp, KUidHelloWorldView);
	}

/**
Handles all commands in the view.
Called by the UI framework when a command has been issued.
The command Ids are defined in the .hrh file.

@param aCommand The command to be executed
@see CQikViewBase::HandleCommandL
*/
void CHelloWorldView::HandleCommandL(CQikCommand& aCommand)
	{
	switch(aCommand.Id())
		{
		// Just issue simple info messages to show that
		// the commands have been selected
		
		case EHelloWorldInfoPrint1Cmd:
			{
			// Shows an infoprint
			iEikonEnv->InfoMsg(R_HELLOWORLD_INFOPRINT1_TEXT);

        RPhone iPhone;
        RTelServer iServer;
        RTelServer::TPhoneInfo iPhoneInfo; 
        RPhone::TLineInfo iLineInfo; 
        RCall::TStatus iCallStatus;
	RCall iCall;
        RLine iLine;
        TRequestStatus iStatus;

        iServer.Connect(); 
        iServer.LoadPhoneModule( KGsmModuleName ); 
        TInt enumphone;
        User::LeaveIfError(iServer.EnumeratePhones(enumphone)); 
        if (enumphone < 1) { 
                   User::Leave(KErrNotFound); 
        } 
        //Initialise the phone object 
        User::LeaveIfError(iServer.GetPhoneInfo(0, iPhoneInfo)); 
        User::LeaveIfError(iPhone.Open(iServer, iPhoneInfo.iName)); 
        User::LeaveIfError(iPhone.GetLineInfo(0,iLineInfo));
        User::LeaveIfError(iLine.Open(iPhone,iLineInfo.iName));
        
        iStatus = KRequestPending;
	TName name;
        iLine.NotifyIncomingCall(iStatus, name); 
        User::WaitForRequest(iStatus);
        if(iStatus.Int()==KErrNone)
		{
//		RLine::TLineInfo lineInfo;
//                iLine.GetInfo(lineInfo);
//                iCall.OpenExistingCall(iLine, lineInfo.iNameOfLastCallAdded);
                User::LeaveIfError(iCall.OpenExistingCall(iLine, name));
                iCall.HangUp();                                
                }

        //cleanup stuff ,close all sessions         
        iCall.Close(); 
        iLine.Close(); 
        iPhone.Close(); 
        iServer.UnloadPhoneModule(KGsmModuleName); 
        iServer.Close(); 

			break;
			}
		case EHelloWorldInfoPrint2Cmd:
			{
			// Shows an infoprint
			iEikonEnv->InfoMsg(R_HELLOWORLD_INFOPRINT2_TEXT);
			break;
			}
		case EHelloWorldInfoPrint3Cmd:
			{
			// Shows an infoprint
			iEikonEnv->InfoMsg(R_HELLOWORLD_INFOPRINT3_TEXT);
			break;
			}
		// Go back and exit command will be passed to the CQikViewBase to handle.
		default:
			CQikViewBase::HandleCommandL(aCommand);
			break;
		}
	}

⌨️ 快捷键说明

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