- 因为涉及到三版和二版两个版本的API,所以我先发个二版的(其实也就是来电检测不同),要用到的能力有
NetworkControl,NetworkServices,ReadUserData,SwEvent,WriteDeviceData
下面是H文件
- /*
- * CTelDial.h
- *
- * Created on: 2009年9月18日
- * Author: snowind
- */
- #ifndef CTELDIAL_H_
- #define CTELDIAL_H_
- //etel core api
- #include
- #include
- #include
- //for the vibra and ring
- #include
- #include
- #include
- #include
- #include //CR Keys To
Control Phone Volume
- #include //CRepository
- //for the light
- #include
- //for the loud speaker
- #include
- #include
- //simulation key
- #include
- class CTelDial: public CActive
- {
- public:
-
- static CTelDial* NewL();
-
- void GetDefaultTSY(TDes& aTSYName);
-
- void StartObserve();
- //the dial
-
- void GetDialNumber();
-
- void SetDialNumber(const TDes& aSetDialNumber);
-
- bool CmpDialedNumber();
-
- void OpenLoudSpeaker();
-
- void SetCallVolumn(const TInt aspeakvol);
-
- //the receive
- void GetReceivedNumber();
-
- void SetReceiveNumber(const TDes&
aSetReceiveNumber);
-
- bool CmpReceivedNumber();
-
- //detect
-
- void SetDetectNumber(const TDes&
aSetDetectNumber);
-
- bool CmpDetectNumber();
-
- //light and vibra
-
- void SetVibraAndRing();
-
- void RecoverVibraAndRing();
-
- //simulate key
-
- void SimulateRedKey();
-
- void SimulateRightKey();
-
- //release
-
- void ReleaseOneCall();
-
- ~CTelDial();
-
- protected:
-
- void RunL();
-
- void DoCancel();
-
- private:
-
- CTelDial();
-
- void ConstructL();
-
- static CTelDial* NewLC();
-
- private:
- //const TUid KUidSound =0x101f8798;
- //Etel Api
- private:
-
- TBuf <20>iTSYName;
- RTelServer iServer;
- RPhone iPhone;
- RPhone::TLineInfo iphonelineinfo;
- RLine iLine;
- RLine::TLineInfo ilineinfo;
- RCall::TStatus iCallStatus;
- //from the etelmm
- RMobileCall iMCall;
- //the numbers
- private:
- TBuf <11> iNumberDial;
- TBuf <11> iNumberReceive;
- TBuf <11> iNumberDialSet;
- TBuf <11> iNumberReceiveSet;
- TBuf <11> iNumberDetectSet;
- //to change the repository
- private:
- CRepository* irepository;
-
- //for the vibra and ring
- private:
- TBool ivibratype;
- TProfileRingingType iRingingType;
-
- private:
- CHWRMLight* ilight;
-
- private:
- RWindowGroup iwindowgroup;
-
- //simulate key
- private:
- RWsSession ws;
- TRawEvent ev1;
-
-
- };
- #endif /* CTELDIAL_H_ */
因为电话挂断有两种方法,所我先发所有的函数申明,然后再发不同的地方
- /*
- * CTelDial.cpp
- *
- * Created on: 2009年9月18日
- * Author: snowind
- */
- #include
- #include
- #include "CTelDial.h"
- //constructed function
- void CTelDial::ConstructL()
- {
- //add the cteldial to the active scheduler
- CActiveScheduler::Add(this);
- ilight = CHWRMLight::NewL();
-
- //use the etel core api
- //create a tel server
- User::LeaveIfError(iServer.Connect()); //connect
- //get the number of phones in the server
- TInt numberphones;
-
User::LeaveIfError(iServer.EnumeratePhones(numberphones));
- //get the default tsy
- GetDefaultTSY(iTSYName);
- //load the tsy module
- User::LeaveIfError(iServer.LoadPhoneModule(iTSYName));
- //get the first phone's info
- RTelServer::TPhoneInfo iPhoneinfo;
- User::LeaveIfError(iServer.GetPhoneInfo(0,
iPhoneinfo));
- //use this info to connect the phone
- User::LeaveIfError(iPhone.Open(iServer,
iPhoneinfo.iName));
- iPhone.Initialise();
- //get the number of line
- TInt numberline;
- User::LeaveIfError(iPhone.EnumerateLines(numberline));
- User::LeaveIfError(iPhone.GetLineInfo(0,
iphonelineinfo));
- User::LeaveIfError(iLine.Open(iPhone,
iphonelineinfo.iName));
- }
- //----------------------------------------------------
- //CTelDial::StartObserve()
- //observe the call
- //----------------------------------------------------
- void CTelDial::StartObserve()
- {
- Cancel();
- //if the status of line changes, it means some one is
calling this phone
- iLine.NotifyStatusChange(iStatus, iCallStatus);
- //invoke the asynchronous function
- SetActive();
- }
- //----------------------------------------------------
- //CTelDial::SetVibraAndRing()
- //turn off the vibra and ring
- //----------------------------------------------------
- void CTelDial::SetVibraAndRing()
- {
- MProEngEngine* iEngine = ProEngFactory::NewEngineL();
- MProEngProfile* iProfile =
iEngine->ActiveProfileLC();
- MProEngToneSettings& iToneSetting =
iProfile->ToneSettings();
- //get the status of vibra, if vibra is on, turn off it
- ivibratype = iToneSetting.VibratingAlert();
- if (ivibratype)
- {
- iToneSetting.SetVibratingAlert(EFalse);
- }
- //get the status of vibra, turn off the ring
- iRingingType = iToneSetting.RingingType();
- if (EProfileRingingTypeSilent != iRingingType)
- {
-
iToneSetting.SetRingingType(EProfileRingingTypeSilent);
- }
-
- //execute the orders
- iProfile->CommitChangeL();
- //must release the MPorEngProfile and MProEngEngine
everytime
- iProfile->Release();
- iEngine->Release();
- }
- //----------------------------------------------------
- //CTelDial::RecoverVibraAndRing()
- //recover the vibra and ring
- //----------------------------------------------------
- void CTelDial::RecoverVibraAndRing()
- {
- MProEngEngine* iEngine = ProEngFactory::NewEngineL();
- MProEngProfile* iProfile =
iEngine->ActiveProfileLC();
- MProEngToneSettings& iToneSetting =
iProfile->ToneSettings();
- //recover
- iToneSetting.SetVibratingAlert(ivibratype);
- iToneSetting.SetRingingType(iRingingType);
- iProfile->CommitChangeL();
- iProfile->Release();
- iEngine->Release();
- }
- void CTelDial::ReleaseOneCall()
- {
- iMCall.Close();
-
- }
- //----------------------------------------------------
- //CTelDial::GetReceivedNumber()
- //get the incoming call number
- //----------------------------------------------------
- void CTelDial::GetReceivedNumber()
- {
- //for the etelmm in the 2nd
- //for the incoming call number
- TInt theerr;
- RMobileCall::TMobileCallInfoV1 remotePartyInfo;
- RMobileCall::TMobileCallInfoV1Pckg
remotePartyInfopckg(remotePartyInfo);
- //this is the key place, at first, the solution from
wiki
- //of nokia official website is below:
- //the two functions are:
- //User::LeaveIfError(theerr = iLine.GetCallInfo(0,
ilinecallinfo));
- //User::LeaveIfError(theerr =
iCall.OpenExistingCall(iLine, ilinecallinfo.iCallName));
- //however, those are wrong, the correct solution is
below:
- User::LeaveIfError(theerr = iLine.GetInfo(ilineinfo));
- User::LeaveIfError(theerr =
iMCall.OpenExistingCall(iLine,
- ilineinfo.iNameOfCallForAnswering));
- User::LeaveIfError(theerr =
iMCall.GetMobileCallInfo(remotePartyInfopckg));
- // Tried this also -
telNumber.Append(iRemotePartyInfo.iRemoteParty.iRemoteNumber.iTelNumber);
-
iNumberReceive.Copy(remotePartyInfopckg().iRemoteParty.iRemoteNumber.iTelNumber);
-
//iNumberDial.Copy(remotePartyInfo.iDialledParty.iTelNumber);
- //this is also OK
- }
- //----------------------------------------------------
- //CTelDial::GetDialNumber()
- //get the outgoing call number
- //----------------------------------------------------
- void CTelDial::GetDialNumber()
- {
- //for the etelmm in the 2nd
- //for the outgoing call number
- TInt theerr;
- RMobileCall::TMobileCallInfoV1 remotePartyInfo;
- RMobileCall::TMobileCallInfoV1Pckg
remotePartyInfopckg(remotePartyInfo);
- //this is the key place, at first, the solution from
wiki
- //of nokia official website is below:
- //the two functions are:
- //User::LeaveIfError(theerr = iLine.GetCallInfo(0,
ilinecallinfo));
- //User::LeaveIfError(theerr =
iCall.OpenExistingCall(iLine, ilinecallinfo.iCallName));
- //however, those are wrong, the correct solution is
below:
- User::LeaveIfError(theerr = iLine.GetInfo(ilineinfo));
- User::LeaveIfError(theerr =
iMCall.OpenExistingCall(iLine,
- ilineinfo.iNameOfLastCallAdded));
- User::LeaveIfError(theerr =
iMCall.GetMobileCallInfo(remotePartyInfopckg));
- // Tried this also -
telNumber.Append(iRemotePartyInfo.iRemoteParty.iRemoteNumber.iTelNumber);
-
iNumberDial.Copy(remotePartyInfopckg().iDialledParty.iTelNumber);
- //this is also
OK iNumberDial.Copy(remotePartyInfo.iDialledParty.iTelNumber);
- }
- bool CTelDial::CmpDialedNumber()
- {
- if (iNumberDialSet == iNumberDial)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool CTelDial::CmpReceivedNumber()
- {
- if (iNumberReceiveSet == iNumberReceive)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool CTelDial::CmpDetectNumber()
- {
- if (iNumberDetectSet == iNumberReceive)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- void CTelDial::SetDialNumber(const TDes& aSetDialNumber)
- {
- iNumberDialSet.Copy(aSetDialNumber);
- }
- void CTelDial::SetReceiveNumber(const TDes&
aSetReceiveNumber)
- {
- iNumberReceiveSet.Copy(aSetReceiveNumber);
- }
- void CTelDial::SetDetectNumber(const TDes&
aSetDetectNumber)
- {
- iNumberDetectSet.Copy(aSetDetectNumber);
- }
- //----------------------------------------------------
- //CTelDial::OpenLoudSpeaker()
- //open the loudspeaker
- //----------------------------------------------------
- void CTelDial::OpenLoudSpeaker()
- {
- TInt value;
- TInt theerr = RProperty::Get(KTelephonyAudioOutput,
KTelephonyAudioOutputPreference, value);
- switch(value)
- {
- case EPSPrivate:
- {
- theerr =
RProperty::Set(KTelephonyAudioOutput,KTelephonyAudioOutputPreference,EPSPublic);
- break;
- }
- // case EPSPublic:
- // {
- // theerr =
RProperty::Set(KTelephonyAudioOutput,KTelephonyAudioOutputPreference,EPSPrivate);
- // break;
- // }
- default:
- break;
- };
- }
- void CTelDial::SetCallVolumn(const TInt aspeakvol)
- {
- //To create a CRepository object for accessing Phone
Volume repository:
- //and it must be created while the phone is processing
- irepository = CRepository::NewL(KCRUidCallHandling);
- //turn the speaker's volumn to max
- TBuf<10> lBufErr;
- TInt lErr =
irepository->Set(KTelephonyIncallLoudspeakerVolume, aspeakvol);
- lBufErr.AppendNum(lErr);
- if (KErrNone != lErr)
- {
- return;
- }
- }
- void CTelDial::SimulateRedKey()
- {
- ws.Connect();
- ev1.Set(TRawEvent::EKeyDown, EStdKeyNo);
- ws.SimulateRawEvent(ev1);
- User::After(100000);
- ev1.Set(TRawEvent::EKeyUp, EStdKeyNo);
- ws.SimulateRawEvent(ev1);
- ws.Flush();
- ws.Close();
- }
- void CTelDial::SimulateRightKey()
- {
- ws.Connect();
- ev1.Set(TRawEvent::EKeyDown, EStdKeyDevice1);
- ws.SimulateRawEvent(ev1);
- User::After(100000);
- ev1.Set(TRawEvent::EKeyUp, EStdKeyDevice1);
- ws.SimulateRawEvent(ev1);
- ws.Flush();
- ws.Close();
- }
- CTelDial::CTelDial() :
- CActive(CActive::EPriorityStandard)
- {
- }
- CTelDial::~CTelDial()
- {
- delete ilight;
- iLine.Close();
- iPhone.Close();
- iServer.UnloadPhoneModule(iTSYName);
- iServer.Close();
- }
- //the three new functions
- CTelDial* CTelDial::NewLC()
- {
- CTelDial* self = new (ELeave) CTelDial;
- CleanupStack::PushL(self);
- self->ConstructL();
- return self;
- }
- CTelDial* CTelDial::NewL()
- {
- CTelDial* self = CTelDial::NewLC();
- CleanupStack::Pop(self);
- return self;
- }
- void CTelDial::DoCancel()
- {
- iLine.NotifyStatusChangeCancel();
- }
- //--------------------------------------
- //CTelDial::GetDefaultTSY(TDes& aTSYName)
- //--------------------------------------
- void CTelDial::GetDefaultTSY(TDes& aTSYName)
- {
- //create a database with unspecified type and push it
into stack
- CCommsDatabase* db =
CCommsDatabase::NewL(EDatabaseTypeUnspecified);
- CleanupStack::PushL(db);
- //create a table
- CCommsDbTableView* table =
db->OpenTableLC(TPtrC(MODEM));
- TInt tabErr;
- User::LeaveIfError(tabErr =
table->GotoFirstRecord());
- TUint32 id;
- table->ReadUintL(TPtrC(COMMDB_ID), id);
- //specified column doesn't exist, then go to the next
record,but y not use circle
- if (id == (TUint32) KDbNullColNo)
- {
- User::LeaveIfError(tabErr =
table->GotoNextRecord());
- table->ReadUintL(TPtrC(COMMDB_ID), id);
- }
- table->ReadTextL(TPtrC(MODEM_TSY_NAME), aTSYName);
- CleanupStack::PopAndDestroy(2);//db,table
- }
然后是发他们有差异的地方,其实就是一个RunL函数
- //RunL ,if the number received is equel to the
setted number
- void CTelDial::RunL()
- {
- //be careful here, this is iStatus.Int(), not just
iStatus
- if (KErrNone == iStatus.Int())
- {
- switch (iCallStatus)
- {
- case RCall::EStatusHangingUp:
- {
- //if press the red key to hang
up the call,
- //just continue turning off
- //the light and release the
memory
-
ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- RProperty::Set(KTelephonyAudioOutput,KTelephonyAudioOutputPreference,EPSPrivate);
- //delete the function of
setting the volumn
- //of call
- if (irepository)
- {
- delete irepository;
- irepository = NULL;
- }
- RecoverVibraAndRing();
- break;
- }
- case RCall::EStatusDialling:
- {
- GetDialNumber();
- if (CmpDialedNumber())
- {
- //use the simulate red
key to hang up
- //SimulateRedKey();
- //or use this API to
hang up
- iMCall.HangUp();
- }
- ReleaseOneCall();
- break;
- }
- case RCall::EStatusRinging:
- {
- //turn off the vibra
- //and ring the moment the phone
is open
- GetReceivedNumber();
- if (CmpReceivedNumber())
- {
- //hang up using the
simulate red key
- //SimulateRedKey();
- //or just Hangup()
- iMCall.HangUp();
ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- }
- //compare the detect number,
- //if it is, answer it.
- else if (CmpDetectNumber())
- {
- SetVibraAndRing();
-
iMCall.AnswerIncomingCall();
- ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- OpenLoudSpeaker();
- //if answer it, turn
off the
- //volumn of call
- SetCallVolumn(0);
- }
- else
- {
- //if it is the normal
call,
- //recover the vibra and
ring
- //turn off it when the
call is over
- RecoverVibraAndRing();
- }
- ReleaseOneCall();
- break;
- }
- default:
- {
- //just turn off the light
-
ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- break;
- }
- }
- }
- //keep observing
- StartObserve();
- }
这是第三版的代码,所谓第三版也只是使用了第三版的API,并不是说只适用于第三版
- /*
- * CTel_3rd.h
- *
- * Created on: 2009年9月20日
- * Author: snowind
- */
- #ifndef CTEL_3RD_H_
- #define CTEL_3RD_H_
- //ctelephony
- #include
- #include
- //#include
- //for the vibra and ring
- #include
- #include
- #include
- #include
- #include //CR Keys To
Control Phone Volume
- #include //CRepository
- //for the light
- #include
- //for the loud speaker
- #include
- #include
- //simulation key
- #include
- class CTelDial: public CActive
- {
- public:
-
- static CTelDial* NewL();
-
- void StartObserve();
- //the dial
-
- void GetDialNumber();
-
- void SetDialNumber(const TDes& aSetDialNumber);
-
- bool CmpDialedNumber();
-
- void OpenLoudSpeaker();
-
- void SetCallVolumn(/*const TInt aearvol, */const TInt
aspeakvol);
-
- //the receive
- void GetReceivedNumber();
-
- void SetReceiveNumber(const TDes&
aSetReceiveNumber);
-
- bool CmpReceivedNumber();
-
- //detect
-
- void SetDetectNumber(const TDes&
aSetDetectNumber);
-
- bool CmpDetectNumber();
-
- //light and vibra
-
- void SetVibraAndRing();
-
- void RecoverVibraAndRing();
-
- //simulate key
-
- void SimulateRightKey();
-
- void SimulateRedKey();
-
- //release
-
- void ReleaseOneCall();
-
- ~CTelDial();
-
- protected:
-
- void RunL();
-
- void DoCancel();
-
- private:
-
- CTelDial();
-
- void ConstructL();
-
- static CTelDial* NewLC();
-
- //ctelephone api
- private:
- CTelephony* itelephony;
- CTelephony::TCallId iCallid;
- CTelephony::TCallStatusV1 iLineStatus;
- CTelephony::TCallStatusV1Pckg iLineStatusPckg;
- CTelephony::TCallStatus iLastInformedLineStatus;
-
- //Etel Api
- private:
-
- TBuf <20>iTSYName;
-
- //the numbers
- private:
- TBuf <11> iNumberDial;
- TBuf <11> iNumberReceive;
- TBuf <11> iNumberDialSet;
- TBuf <11> iNumberReceiveSet;
- TBuf <11> iNumberDetectSet;
- //to change the repository
- private:
- CRepository* irepository;
-
- //for the vibra and ring
- private:
- TBool ivibratype;
- TProfileRingingType iRingingType;
-
- private:
- CHWRMLight* ilight;
-
- private:
- RWindowGroup iwindowgroup;
-
- //simulate key
- private:
- RWsSession ws;
- TRawEvent ev1;
- TRawEvent ev2;
-
- };
- #endif /* CTELDIAL_H_ */
这是第三版的类的定义
- /*
- * CTel_3rd.cpp
- *
- * Created on: 2009年10月26日
- * Author: Administrator
- */
- #include
- #include
- #include "CTel_3rd.h"
- //constructed function
- void CTelDial::ConstructL()
- {
- //add the cteldial to the active scheduler
- CActiveScheduler::Add(this);
- ilight = CHWRMLight::NewL();
-
- itelephony = CTelephony::NewL();
-
- // iwindowgroup.CaptureKey(EStdKey)
- }
- //RunL ,if the number received is equel to the setted number
- void CTelDial::RunL()
- {
- if (KErrNone == iStatus.Int())
- {
- switch (iLineStatus.iStatus)
- {
- case CTelephony::EStatusDisconnecting:
- {
-
ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
-
RProperty::Set(KTelephonyAudioOutput,KTelephonyAudioOutputPreference,EPSPrivate);
- if (irepository)
- {
- delete irepository;
- irepository = NULL;
- }
- break;
- }
- case CTelephony::EStatusDialling:
- {
- GetDialNumber();
- if (CmpDialedNumber())
- {
- SimulateRedKey();
- }
- break;
- }
- case CTelephony::EStatusRinging:
- {
- //turn off the vibra and ring
the moment the phone is open
- GetReceivedNumber();
- if (CmpReceivedNumber())
- {
- SimulateRedKey();
-
ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- }
- //compare the detect number, if
it is, answer it.
- else if (CmpDetectNumber())
- {
- // SetVibraAndRing();
- //this is to turn off
the ring
- SimulateRightKey();
-
itelephony->AnswerIncomingCall(iStatus, iCallid);
-
//ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- OpenLoudSpeaker();
- SetCallVolumn(0);
- }
- else
- {
- //if it's the normal
call, recover the vibra and ring
- //turn off it when the
call is over
- RecoverVibraAndRing();
- }
- break;
- }
- default:
- {
-
ilight->LightOffL(CHWRMLight::EPrimaryDisplayAndKeyboard);
- break;
- }
- }
- }
- Cancel();
- //if the status of line changes, it means some one is
calling this phone
- itelephony->NotifyChange(iStatus,
-
CTelephony::EVoiceLineStatusChange,
-
iLineStatusPckg);
- }
- //----------------------------------------------------
- //CTelDial::StartObserve()
- //observe the call
- //----------------------------------------------------
- void CTelDial::StartObserve()
- {
- Cancel();
- //if the status of line changes, it means some one is
calling this phone
- itelephony->NotifyChange(iStatus,
-
CTelephony::EVoiceLineStatusChange,
-
iLineStatusPckg);
- SetActive();//invoke the asynchronous function
- }
- //----------------------------------------------------
- //CTelDial::SetVibraAndRing()
- //turn off the vibra and ring
- //----------------------------------------------------
- void CTelDial::SetVibraAndRing()
- {
- MProEngEngine* iEngine = ProEngFactory::NewEngineL();
- MProEngProfile* iProfile =
iEngine->ActiveProfileLC();
- MProEngToneSettings& iToneSetting =
iProfile->ToneSettings();
- //if vibra is on, turn off it
- ivibratype = iToneSetting.VibratingAlert();
- if (ivibratype)
- {
- iToneSetting.SetVibratingAlert(EFalse);
- }
- //turn off the ring
- iRingingType = iToneSetting.RingingType();
- if (EProfileRingingTypeSilent != iRingingType)
- {
-
iToneSetting.SetRingingType(EProfileRingingTypeSilent);
- }
- iProfile->CommitChangeL();
- iProfile->Release();
- iEngine->Release();
- }
- //----------------------------------------------------
- //CTelDial::RecoverVibraAndRing()
- //recover the vibra and ring
- //----------------------------------------------------
- void CTelDial::RecoverVibraAndRing()
- {
- MProEngEngine* iEngine = ProEngFactory::NewEngineL();
- MProEngProfile* iProfile =
iEngine->ActiveProfileLC();
- MProEngToneSettings& iToneSetting =
iProfile->ToneSettings();
- //recover
- iToneSetting.SetVibratingAlert(ivibratype);
- iToneSetting.SetRingingType(iRingingType);
- iProfile->CommitChangeL();
- iProfile->Release();
- iEngine->Release();
- }
- //----------------------------------------------------
- //CTelDial::GetReceivedNumber()
- //get the incoming call number
- //----------------------------------------------------
- void CTelDial::GetReceivedNumber()
- {
- //in the 3rd
- CTelephony::TCallInfoV1 iPhonyCallInfoV1;
- CTelephony::TCallInfoV1Pckg
iPhonyCallInfoV1Pckg(iPhonyCallInfoV1);
-
- CTelephony::TCallSelectionV1 iPhonyCallSelectionV1;
- CTelephony::TCallSelectionV1Pckg
iPhonyCallSelectionV1Pckg(iPhonyCallSelectionV1);
-
- CTelephony::TRemotePartyInfoV1 iPhonyRemotePartyInfoV1;
- CTelephony::TRemotePartyInfoV1Pckg
iPhonyRemotePartyInfoV1Pckg( iPhonyRemotePartyInfoV1 );
-
- CTelephony::TCallStatusV1 iPhonyCallStatusV1;
- CTelephony::TCallStatusV1Pckg
iPhonyCallStatusV1Pckg(iPhonyCallStatusV1);
-
-
- iPhonyCallSelectionV1.iLine = CTelephony::EVoiceLine;
- iPhonyCallSelectionV1.iSelect =
CTelephony::EInProgressCall;
-
- itelephony->GetLineStatus(CTelephony::EVoiceLine,
iPhonyCallStatusV1Pckg);
- itelephony->GetCallInfo(iPhonyCallSelectionV1Pckg,
iPhonyCallInfoV1Pckg, iPhonyRemotePartyInfoV1Pckg);
-
- if (CTelephony::ERemoteIdentityAvailable ==
iPhonyRemotePartyInfoV1.iRemoteIdStatus)
- {
- if
(iPhonyRemotePartyInfoV1.iRemoteNumber.iTelNumber.Length() > 0)
- {
- //Incoming call number
- iNumberReceive =
iPhonyRemotePartyInfoV1.iRemoteNumber.iTelNumber;
- }
- }
- }
- //----------------------------------------------------
- //CTelDial::GetDialNumber()
- //get the outgoing call number
- //----------------------------------------------------
- void CTelDial::GetDialNumber()
- {
- CTelephony::TCallInfoV1 iPhonyCallInfoV1;
- CTelephony::TCallInfoV1Pckg
iPhonyCallInfoV1Pckg(iPhonyCallInfoV1);
-
- CTelephony::TCallSelectionV1 iPhonyCallSelectionV1;
- CTelephony::TCallSelectionV1Pckg
iPhonyCallSelectionV1Pckg(iPhonyCallSelectionV1);
-
- CTelephony::TRemotePartyInfoV1 iPhonyRemotePartyInfoV1;
- CTelephony::TRemotePartyInfoV1Pckg
iPhonyRemotePartyInfoV1Pckg( iPhonyRemotePartyInfoV1 );
-
-
- iPhonyCallSelectionV1.iLine = CTelephony::EVoiceLine;
- iPhonyCallSelectionV1.iSelect =
CTelephony::EInProgressCall;
-
- itelephony->GetCallInfo(iPhonyCallSelectionV1Pckg,
iPhonyCallInfoV1Pckg, iPhonyRemotePartyInfoV1Pckg);
-
- if (iPhonyCallInfoV1.iDialledParty.iTelNumber.Length()
> 0)
- {
- //Outgoing call number
- iNumberDial =
iPhonyCallInfoV1.iDialledParty.iTelNumber;
- }
- }
- bool CTelDial::CmpDialedNumber()
- {
- if (iNumberDialSet == iNumberDial)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool CTelDial::CmpReceivedNumber()
- {
- if (iNumberReceiveSet == iNumberReceive)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- bool CTelDial::CmpDetectNumber()
- {
- if (iNumberDetectSet == iNumberReceive)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- void CTelDial::SetDialNumber(const TDes& aSetDialNumber)
- {
- iNumberDialSet.Copy(aSetDialNumber);
- }
- void CTelDial::SetReceiveNumber(const TDes&
aSetReceiveNumber)
- {
- iNumberReceiveSet.Copy(aSetReceiveNumber);
- }
- void CTelDial::SetDetectNumber(const TDes&
aSetDetectNumber)
- {
- iNumberDetectSet.Copy(aSetDetectNumber);
- }
- //----------------------------------------------------
- //CTelDial::OpenLoudSpeaker()
- //open the loudspeaker
- //----------------------------------------------------
- void CTelDial::OpenLoudSpeaker()
- {
- TInt value;
- TInt theerr = RProperty::Get(KTelephonyAudioOutput,
KTelephonyAudioOutputPreference, value);
- switch(value)
- {
- case EPSPrivate:
- {
- theerr =
RProperty::Set(KTelephonyAudioOutput,KTelephonyAudioOutputPreference,EPSPublic);
- break;
- }
- default:
- break;
- };
- }
- void CTelDial::SetCallVolumn(const TInt aspeakvol)
- {
- //To create a CRepository object for accessing Phone
Volume repository:
- //and it must be created while the phone is processing
- irepository = CRepository::NewL(KCRUidCallHandling);
- //turn the speaker's volumn to max
- TBuf<10> lBufErr;
- TInt lErr =
irepository->Set(KTelephonyIncallLoudspeakerVolume, aspeakvol);
- lBufErr.AppendNum(lErr);
- if (KErrNone != lErr)
- {
- return;
- }
- }
- void CTelDial::SimulateRedKey()
- {
- ws.Connect();
- ev1.Set(TRawEvent::EKeyDown, EStdKeyNo);
- ws.SimulateRawEvent(ev1);
- User::After(100000);
- ev1.Set(TRawEvent::EKeyUp, EStdKeyNo);
- ws.SimulateRawEvent(ev1);
- ws.Flush();
- }
- void CTelDial::SimulateRightKey()
- {
- ws.Connect();
- ev2.Set(TRawEvent::EKeyDown, EKeyDevice1);
- ws.SimulateRawEvent(ev2);
- User::After(100000);
- ev2.Set(TRawEvent::EKeyUp, EKeyDevice1);
- ws.SimulateRawEvent(ev2);
- ws.Flush();
- }
- CTelDial::CTelDial() :
-
CActive(CActive::EPriorityStandard),iLineStatusPckg(iLineStatus)
- {
- iLineStatus.iStatus = CTelephony::EStatusUnknown;
- }
- void CTelDial::DoCancel()
- {
-
itelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
- }
- CTelDial::~CTelDial()
- {
- delete ilight;
- }
- //the three new functions
- CTelDial* CTelDial::NewLC()
- {
- CTelDial* self = new (ELeave) CTelDial;
- CleanupStack::PushL(self);
- self->ConstructL();
- return self;
- }
- CTelDial* CTelDial::NewL()
- {
- CTelDial* self = CTelDial::NewLC();
- CleanupStack::Pop(self);
- return self;
- }
阅读(1348) | 评论(0) | 转发(0) |