亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ansphoneengine.cpp

?? s60 接打電話代碼,很有學(xué)習(xí)價(jià)值的,可以移植到不同平臺(tái)
?? CPP
字號(hào):
/**
*
* @brief Definition of CAnsPhoneEngine
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

#include "AnsPhoneEngine.h"

#include <bautils.h>    // BaflUtils
#include <aknutils.h>    // BaflUtils

_LIT(KYourMessageFileName, "\\system\\apps\\AnsPhone\\yourmes.wav");
_LIT(KTheirMessageFileName, "\\system\\apps\\AnsPhone\\theirmes.wav");
_LIT(KMessagesDir, "c:\\system\\apps\\AnsPhone\\messages\\");

_LIT(KTSY, "phonetsy");
_LIT(KMessageType, ".wav");


const TInt KSpace = 32;

const TInt KMaxMessages = 5;
const TInt KDelay = 10000;
const TInt KHalfSecond = 500000;

const TInt KGranMessages = 5;


CAnsPhoneEngine::CAnsPhoneEngine(MAnsPhoneEngineObserver& aObserver)
:iObserver(aObserver),
 iState(ENoState),
 iIsLocal(EFalse)
	{
	}

CAnsPhoneEngine::~CAnsPhoneEngine()
	{
	if (iTimer)
        {
		iTimer->Cancel();
	    delete iTimer;
        }

    SoundCleanup();

	delete iMessageList;

	TelephonyCleanup();

    iFs.Close();
	}

CAnsPhoneEngine* CAnsPhoneEngine::NewL(MAnsPhoneEngineObserver& aObserver)
	{
	CAnsPhoneEngine* self = new (ELeave) CAnsPhoneEngine(aObserver);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

void CAnsPhoneEngine::ConstructL()
	{
    User::LeaveIfError(iFs.Connect());

	// create the messages directory if it does not exist
    if (!BaflUtils::PathExists(iFs, KMessagesDir))
    	User::LeaveIfError(iFs.MkDirAll(KMessagesDir));

	iMessageList = new (ELeave) CArrayFixSeg<TMessage>(KGranMessages);

	// load the messages from the messages directory
	CDir* dir = NULL;
	User::LeaveIfError(iFs.GetDir(KMessagesDir, KEntryAttNormal, ESortByDate|EDescending, dir));
	CleanupStack::PushL(dir);

	TInt numberFiles = dir->Count();
	for(TInt a = 0; a < numberFiles; a++)
		{
		const TEntry& file = (*dir)[a];
		TMessage message;
		message.iNumber = file.iName;
		message.iTime	= file.iModified;
		iMessageList->AppendL(message);
		}

	CleanupStack::PopAndDestroy(dir);
	}


void CAnsPhoneEngine::MoscoStateChangeEventL(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt aCurrentState, TInt aErrorCode)
	{
	// if the recording has died, this means that the recording should be finished;
	// should only happen when recording on the telephony line
	if(iState == ERecord && !iIsLocal && aErrorCode == KErrDied)
		{
		Stop();
		return;
		}

	User::LeaveIfError(aErrorCode);

	if(aCurrentState != CMdaAudioClipUtility::EOpen)
		return;

	switch(iState)
		{
		case ERecordInit:
			// Record from the telephony line and set to max gain
			if(iIsLocal)
				{
				iSound->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal);
				iSound->SetGain(iSound->MaxGain());
				}
			else
				{
				iSound->SetAudioDeviceMode(CMdaAudioRecorderUtility::ETelephonyNonMixed);
				TInt maxGain = iSound->MaxGain();
				iSound->SetGain(maxGain / 2);
				}

			// Delete current audio sample from beginning of file
			iSound->SetPosition(TTimeIntervalMicroSeconds(0));
			iSound->CropL();

			// start recording
			iSound->RecordL();
			iState = ERecord;
			break;

		case ERecord:
			break;

		case EPlayInit:
			{
			// Play through the device speaker and set to max volume
			if(iIsLocal)
				{
				iSound->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal);
				}
			else
				{
				iSound->SetAudioDeviceMode(CMdaAudioRecorderUtility::ETelephonyOrLocal);
//				iPhone.DeviceSpeakerOff();
				}
			iSound->SetVolume(iSound->MaxVolume());

			// Set the playback position to the start of the file
			iSound->SetPosition(TTimeIntervalMicroSeconds(0));
			iSound->PlayL();
			iState = EPlay;

			// we start the timer
			// add a half a second onto the play time to make sure we've finished playing
			TInt64 playTime = iSound->Duration().Int64() + KHalfSecond;
            if (iTimer)
                {
                delete iTimer;
                iTimer = NULL;
                }
			iTimer = CAnsPhoneTimer::NewL(*this, playTime.GetTInt());
			break;
			}
		default:
			break;
		}
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// MMdaObjectStateChangeObserver
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

void CAnsPhoneEngine::MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
// this function is called by the CMdaAudioRecorderUtility object
// it handles starting playing/recording and stopping the recording when the call has ended
//
//	Note:
//	When the CMdaAudioRecorderUtility plays/records a message, the function SetAudioDeviceMode()
//	sets how the device mixes the microphone and telephony downlink
//	CMdaAudioRecorderUtility::ETelephonyNonMixed should there should be no mixing between
//	device speaker/microphone and the telephony downlink. However, this does not work and so
//	when playing/recording during a call, the sound microphone is mixed with the telephony downlink
//	One way to prevent this for recording is to set the volume to zero; this means the user cannot
//	hear what the other person is recording. This cannot be done when playing because the downlink
//	will have a volume of zero as well.
	{
	TRAPD (err, MoscoStateChangeEventL(aObject, aPreviousState, aCurrentState, aErrorCode))
	if (err)
		{
		Stop();
		}
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// MAnsPhoneTimerObserver
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

void CAnsPhoneEngine::TimerCompleteL()
// play has finished, so either alert the observer or start recording
	{
	// check for having cancelled the playing/recording before they have finished
	// this will happen if the person hangs up before the playing has finished
	if(iState == ENoState)
		return;

	delete iTimer;
	iTimer = NULL;

	iState = ENoState;
	SoundCleanup();

	if(iIsLocal)
		{
		iObserver.HandlePlayMessageOverL();
		}
	else
		{
		TMessage message;
		TTime time;
		time.HomeTime();
		message.iTime = time;
		iMessageList->InsertL(0, message);

		RecordMessageL(EFalse);
		}
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// MAnsPhoneCallWatcherObserver
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

void CAnsPhoneEngine::HandleCallInChangeL(const RCall::TStatus& aStatus)
	{
	switch(aStatus)
		{
		case RCall::EStatusConnected:
			{
			iObserver.HandleCallChangeL(aStatus);
			PlayMessageL(EFalse, 0, ETrue);
			break;
			}
		case RCall::EStatusHangingUp:
			// if we have started recording, then tell the observer that we have recorded a new message
			if(iState == ERecord)
				{
				iObserver.HandleNewMessageL();
				iCallLog->GetNumberL();
				}
			// if we have initialized recording without yet recording and the call is hung up,
			// then we want to delete the file we have just created
			else if(iState == ERecordInit)
				{
				iMessageList->Delete(0);
				}

			SoundCleanup();

			iObserver.HandleCallChangeL(aStatus);

			break;
		default:
			break;
		}
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////
// MAnsPhoneCallMakerObserver
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

void CAnsPhoneEngine::HandleCallHungUpL()
	{
	iObserver.HandleCallChangeL(RCall::EStatusUnknown);
	delete iCallMaker;
	iCallMaker = NULL;

	if(!iCallWatcher)
		{
		iLine.Close();
		iSession.Close();
		}
	}
///////////////////////////////////////////////////////////////////////////////////////////////////////
// MAnsPhoneCallLogObserver
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

void CAnsPhoneEngine::HandlePhoneNumberL(const TDesC& aNumber)
// the logger has completed with the phone number that called, so
// copy the file to the new name for the number and update the messages list with this new name
	{
	// get the next file in the list
	TFileName file;
	GetNextMessageFileName(file, aNumber);

	TMessage& message = iMessageList->At(0);
	message.iNumber = file;
	file.Insert(0, KMessagesDir);

	TFileName fileName (KTheirMessageFileName);
	CompleteWithAppPath (fileName);
	iFs.Rename(fileName, file);
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

void CAnsPhoneEngine::AnsweringStartL()
// starts the answering machine
	{
	TelStartL();
	iCallWatcher = CAnsPhoneCallWatcher::NewL(*this, iLine);
	iCallLog = CAnsPhoneCallLog::NewL(*this);
	}

void CAnsPhoneEngine::AnsweringStop()
// stops the answering machine
	{
	TelephonyCleanup();
	}

void CAnsPhoneEngine::PlayMessageL(TBool aIsLocal, TInt aIndex, TBool aIsUsers)
	{
	SoundCleanup();
	iSound = CMdaAudioRecorderUtility::NewL(*this);

	if(aIsUsers)
		{
		TFileName fileName (KYourMessageFileName);
		CompleteWithAppPath (fileName);
		iSound->OpenFileL(fileName);
		}
	else
		{
		TFileName file = iMessageList->At(aIndex).iNumber;
		file.Insert(0, KMessagesDir);
		iSound->OpenFileL(file);
		}

	iState = EPlayInit;
	iIsLocal = aIsLocal;
	}

void CAnsPhoneEngine::RecordMessageL(TBool aIsLocal)
// records a message;
//	if aIsLocal = ETrue, then record to the user's message;		use the telephony line
//	if aIsLocal = EFalse, then record to aFileName;				use the device microphone
//
//	there are several ways to record to a file by the CMdaAudioRecorderUtility:
//	->	use OpenFileL()
//		if we use this method, then the file must all ready exist, and just creating a new file using
//		RFile.CreateL() or RFile.ReplaceL() will not be accepted by the recorder utility
//		therefore, this would put a limit on how many messages could be kept
//	->	use OpenL()
//		if we use this method, then the file name passed to it, will lead it to construct a new file
//		with this filename or it will overwrite an existing file with that name
//		however, in order to use this function, we need to pass in several objects:
//		->	file location
//		->	file format to be recorded, this is populated by the function
//		->	recording codec to use
//		->	audio settings, such as sample rate and number of channels
	{
	SoundCleanup();

	iSound = CMdaAudioRecorderUtility::NewL(*this);

	iMessageCodec.iBits = TMdaPcmWavCodec::E16BitPcm;
	iMessageSettings.iCaps = TMdaAudioDataSettings::ESampleRateFixed | TMdaAudioDataSettings::ESampleRate8000Hz | TMdaAudioDataSettings::EChannelsMono;
	iMessageSettings.iSampleRate = 8000;
	iMessageSettings.iChannels = 1;

	if(aIsLocal)
		{
		TFileName fileName (KYourMessageFileName);
		CompleteWithAppPath (fileName);
		iMessageLocation.iName = fileName;
		}
	else
		{
		TFileName fileName (KTheirMessageFileName);
		CompleteWithAppPath (fileName);
		iMessageLocation.iName = fileName;
		}

	iSound->OpenL(&iMessageLocation, &iMessageFormat, &iMessageCodec, &iMessageSettings);

	iState = ERecordInit;
	iIsLocal = aIsLocal;
	}

void CAnsPhoneEngine::Stop()
	{
	SoundCleanup();
	}

void CAnsPhoneEngine::TelStartL()
// starts the telephony server and line;
// this does not start up the call watcher
// this is used when dialling
	{
	// if the call watcher is up and running, then we have all ready started the telephony server and line
	if(iCallWatcher)
		return;

	User::LeaveIfError(iSession.Connect());
	// load the appropriate tsy
	User::LeaveIfError(iSession.LoadPhoneModule(KTSY));

	// in order to get a handle on a line, we must get a handle on an RPhone object
	TInt numberPhones = 0;
	User::LeaveIfError(iSession.EnumeratePhones(numberPhones));
	if(!numberPhones)
		User::Leave(KErrNotFound);

	// we use the 1st available phone
	RTelServer::TPhoneInfo phoneInfo;
	User::LeaveIfError(iSession.GetPhoneInfo(0, phoneInfo));
	User::LeaveIfError(iPhone.Open(iSession, phoneInfo.iName));

	// we must now find a line that will accept voice calls
	TInt numberLines = 0;
	User::LeaveIfError(iPhone.EnumerateLines(numberLines));
	RPhone::TLineInfo lineInfo;
	TBool foundLine = EFalse;
	for(TInt a = 0; a < numberLines; a++)
		{
		User::LeaveIfError(iPhone.GetLineInfo(a, lineInfo));
		if(lineInfo.iLineCapsFlags & RLine::KCapsVoice)
			{
			foundLine = ETrue;
			break;
			}
		}

	if(!foundLine)
		User::Leave(KErrNotFound);

	User::LeaveIfError(iLine.Open(iPhone, lineInfo.iName));
	}

void CAnsPhoneEngine::SoundCleanup()
	{
	if(iSound)
		{
		iSound->Stop();
		iSound->Close();
		delete iSound;
		iSound = NULL;
		}
	iState = ENoState;
	}

void CAnsPhoneEngine::TelephonyCleanup()
	{
	delete iCallWatcher;
	iCallWatcher = NULL;

	delete iCallMaker;
	iCallMaker = NULL;

    delete iCallLog;
    iCallLog = NULL;

	iPhone.Close();
	iLine.Close();
	iSession.Close();
	}

void CAnsPhoneEngine::DeleteMessage(TInt aIndex)
	{
	TFileName file;
	file.Append(KMessagesDir);
	file.Append(iMessageList->At(aIndex).iNumber);
	iFs.Delete(file);
	iMessageList->Delete(aIndex);
	}

void CAnsPhoneEngine::GetNextMessageFileName(TDes& aFileName, const TDesC& aNumber)
// works out what the appropriate file name is for the next message to be recorded
	{
	TBool foundNumber = EFalse;
	TInt highestIndex = 0;
	TInt numberMessages = iMessageList->Count();
	for(TInt a = 0; a < numberMessages; a++)
		{
		const TMessage& message = iMessageList->At(a);

		TInt index = 0;
		TBuf<KNumberMaxLength> buf;
		TrimIndex(message.iNumber, buf, index);

		if(aNumber.Compare(buf) == 0)
			{
			foundNumber = ETrue;

			if(index > highestIndex)
				highestIndex = index;
			}
		}

	if(!foundNumber)
		{
		aFileName = aNumber;
		}
	else
		{
		aFileName = aNumber;
		aFileName.Append(KSpace);
		aFileName.AppendNum(highestIndex + 1);
		}
	}

void CAnsPhoneEngine::TrimIndex(const TDesC& aBuffer, TDes& aNumber, TInt& aIndex)
// takes aBuffer and works out the number from this and aIndex and populates these arguments
// e.g. "07779238045 5" gives aNumber = "07779239045" and aIndex = 5
	{
	TInt locateSpace = aBuffer.LocateReverse(KSpace);
	if(locateSpace <= 0)
		{
		aNumber = aBuffer;
		aIndex = 0;
		}
	else
		{
		aNumber = aBuffer.Left(locateSpace);
		TBuf<KNumberMaxLength> buf = aBuffer.Right(aBuffer.Length() - locateSpace - 1);
		TLex lex(buf);
		lex.Val(aIndex);
		}
	}

void CAnsPhoneEngine::DialNumberL(TInt aIndex)
// dials the number of the message's number at aIndex in iMessageList
	{
	TelStartL();
	iCallMaker = CAnsPhoneCallMaker::NewL(*this, iLine);
	TBuf<KNumberMaxLength> file = iMessageList->At(aIndex).iNumber;
	TBuf<KNumberMaxLength> number;
	TInt index = 0;
	TrimIndex(file, number, index);

	iCallMaker->MakeCallL(number);
	}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区免费在线观看| 国产亚洲欧洲一区高清在线观看| 国产精品成人免费| 国产69精品久久久久毛片| 国产午夜一区二区三区| 成人精品视频一区| 亚洲欧美欧美一区二区三区| 日本道精品一区二区三区| 亚洲成人一区在线| 欧美va日韩va| 国产成人久久精品77777最新版本| 久久久久久久久久久久久女国产乱| 国产不卡免费视频| 亚洲图片激情小说| 欧美色大人视频| 免费一区二区视频| 国产色91在线| 91激情在线视频| 免费不卡在线观看| 国产精品亲子伦对白| 在线观看一区不卡| 国模冰冰炮一区二区| 国产精品美女一区二区| 欧美吞精做爰啪啪高潮| 蜜臂av日日欢夜夜爽一区| 国产免费成人在线视频| 在线观看不卡一区| 国产一区二区三区| 一区二区三区四区在线| 精品国产一区二区在线观看| 成人午夜看片网址| 天堂成人国产精品一区| 国产调教视频一区| 欧美日韩成人高清| 春色校园综合激情亚洲| 日韩福利电影在线| 国产精品亲子伦对白| 91精品国产欧美一区二区18| 成人一区二区三区视频| 9人人澡人人爽人人精品| 天天色综合天天| 国产精品久久久久一区二区三区| 欧美日韩精品是欧美日韩精品| 国产伦精品一区二区三区免费迷 | 欧美性感一区二区三区| 精品无人区卡一卡二卡三乱码免费卡| 亚洲欧洲精品天堂一级| 精品美女在线播放| 欧美日韩国产在线观看| jlzzjlzz亚洲日本少妇| 蜜臀av性久久久久av蜜臀妖精| 亚洲日韩欧美一区二区在线| 国产亚洲精品aa午夜观看| 欧美裸体bbwbbwbbw| 成人18精品视频| 激情欧美一区二区| 日本美女一区二区三区| 亚洲国产一区二区三区青草影视| 国产精品久久久久久久浪潮网站 | 久久久美女艺术照精彩视频福利播放| 91福利国产成人精品照片| 国产·精品毛片| 国内外成人在线| 久久黄色级2电影| 日韩**一区毛片| 午夜激情一区二区| 亚洲午夜激情av| 亚洲精品午夜久久久| 中文字幕亚洲一区二区av在线| 久久九九久精品国产免费直播| 欧美一区二区黄| 3d成人h动漫网站入口| 欧美日韩国产首页| 欧美日韩视频一区二区| 欧美日韩中字一区| 欧美影院午夜播放| 在线欧美小视频| 在线视频一区二区三区| 91视频国产观看| 91在线视频播放地址| 99精品视频中文字幕| 波多野结衣欧美| www.亚洲精品| 一道本成人在线| 欧美在线一区二区三区| 欧美三级电影一区| 777a∨成人精品桃花网| 欧美精品一级二级| 日韩色视频在线观看| 精品久久久久一区二区国产| 欧美成人猛片aaaaaaa| 2019国产精品| 国产精品的网站| 一区二区三区精品视频| 丝袜美腿亚洲一区二区图片| 麻豆精品久久精品色综合| 狂野欧美性猛交blacked| 国产在线精品国自产拍免费| 粉嫩一区二区三区在线看| 99精品欧美一区二区三区小说 | 国产精品狼人久久影院观看方式| 国产精品久久久久久一区二区三区| 中文字幕中文在线不卡住| 一区二区三区四区av| 亚洲 欧美综合在线网络| 激情深爱一区二区| 91麻豆精东视频| 欧美日韩一区三区四区| 欧美videos大乳护士334| 国产精品久久久久久户外露出| 亚洲最新视频在线观看| 卡一卡二国产精品| 不卡欧美aaaaa| 制服丝袜中文字幕一区| 中文子幕无线码一区tr| 亚洲国产日韩a在线播放性色| 美女一区二区三区| 波多野结衣亚洲| 日韩一区二区三区在线观看| 欧美国产日本视频| 三级精品在线观看| www.久久精品| 精品国免费一区二区三区| 一区在线观看免费| 裸体一区二区三区| 92精品国产成人观看免费| 精品久久久影院| 亚洲综合区在线| 成人午夜视频网站| 日韩一级欧美一级| 亚洲精品国产精品乱码不99| 经典三级视频一区| 欧美日本一区二区三区四区| 国产精品国产三级国产有无不卡| 日韩专区一卡二卡| 色婷婷精品久久二区二区蜜臂av| 欧美成人精品福利| 日韩经典中文字幕一区| 91视频在线观看| 国产日本亚洲高清| 美美哒免费高清在线观看视频一区二区| 91亚洲国产成人精品一区二区三| 日韩欧美一卡二卡| 五月婷婷另类国产| 99久久精品情趣| 欧美精品一区二区三区在线播放| 亚洲777理论| 欧美在线观看一区二区| 国产精品看片你懂得| 国产精品一卡二卡| 欧美成人官网二区| 麻豆国产91在线播放| 欧美日韩国产欧美日美国产精品| 亚洲免费在线观看| 粉嫩在线一区二区三区视频| 精品粉嫩超白一线天av| 蜜桃av一区二区| 日韩一区二区三区电影在线观看| 亚洲成人激情综合网| 日本高清不卡aⅴ免费网站| 1区2区3区欧美| 99re成人在线| 亚洲免费在线播放| 色哟哟精品一区| 国产精品国产精品国产专区不片| 国产精品一二三区| 国产性做久久久久久| 国产精品一区二区视频| 久久综合视频网| 国产精品一区2区| 国产亚洲成年网址在线观看| 国产高清成人在线| 日韩国产精品91| 91精品国产高清一区二区三区| 亚洲成人综合在线| 91精品欧美综合在线观看最新 | 欧美精品一区二区在线观看| 精品一区二区三区免费观看| 精品伦理精品一区| 国产美女精品人人做人人爽| 国产视频一区在线观看| av一本久道久久综合久久鬼色| 国产精品无码永久免费888| av中文字幕不卡| 亚洲精品高清在线观看| 欧美日韩国产在线观看| 裸体歌舞表演一区二区| 亚洲精品一区二区三区蜜桃下载 | 日韩在线a电影| 欧美精品一区二区久久久| 国产剧情一区二区三区| 中文字幕乱码日本亚洲一区二区| av一本久道久久综合久久鬼色| 亚洲视频在线一区| 欧美三级电影网站| 久久成人综合网| 亚洲天堂成人在线观看| 欧美情侣在线播放| 国产老肥熟一区二区三区| 亚洲人亚洲人成电影网站色|