Hi
I found code that can trace a dialing status .
I try to use it in a very simple and primitive way :
I want to hang up the call when status changes to dialing.
what actually happens is that when I dial a number and the app is in the background , I get a message that my app is closed , and the call is made (not hung up).
so the dialing status does activate the RunL() method , but the app falls.
please advise , what should I change or add ?
I put the code below , I think that the most relevant method here is the RunL() ...
Thanks in advance , TE
CActiveClass* CActiveClass::NewL()
{
CActiveClass* self = new (ELeave) CActiveClass();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}CActiveClass::CActiveClass()
: CActive(0){}
void CActiveClass::ConstructL()
{
iEnv = CEikonEnv::Static();
CActiveScheduler::Add(this);
StartObserver();
}
CActiveClass::~CActiveClass()
{
if (IsActive())
{
Cancel();
}
else
{
ReleasePhone();
}
}
void CActiveClass::RunL()
{
if (iStatus == KErrNone)
{
if (iCallStatus == RCall::EStatusHangingUp || iCallStatus == RCall::EStatusIdle || iCallStatus == RCall::EStatusUnknown)
{
iCall.Close();
}
else if(iCallStatus == RCall::EStatusDialling)
{
RCall iCall2;
// Try : iCall2.OpenExistingCall(iPhone,iName);
iCall2.OpenExistingCall(iLine,iName);
// Try : iCall2.DialCancel ();
// Try : iCall2.HangUp(iStatus);
iCall2.HangUp();
}
iLine.NotifyStatusChange(iStatus, iCallStatus);
SetActive();
}
}
void CActiveClass:😃oCancel()
{
ReleasePhone();
}
void CActiveClass::StartObserver()
{
Cancel();
if (InitializePhone() == KErrNone)
{
iLine.NotifyStatusChange(iStatus, iCallStatus);
SetActive();
}
}
TInt CActiveClass::InitializePhone()
{
TInt theError;
if (iLineInited)
{
return KErrNone;
}
theError = iTelServer.Connect();
if (theError)
{
return theError;
}
// Find the number of phones available from the tel server
TInt numberPhones;
theError = iTelServer.EnumeratePhones(numberPhones);
if (theError)
{
iTelServer.Close();
return theError;
}
// Check there are available phones
if (numberPhones < 1)
{
iTelServer.Close();
return KErrNotFound;
}
// Read the TSY module name
theError = iTelServer.GetTsyName(0, iTsyName);
if (theError != KErrNone)
{
iTelServer.Close();
return theError;
}
// Load in the phone device driver
theError = iTelServer.LoadPhoneModule(iTsyName);
if (theError)
{
iTelServer.Close();
return theError;
}
// Get info about the first available phone
RTelServer::TPhoneInfo info;
theError = iTelServer.GetPhoneInfo(0, info);
if (theError)
{
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Use this info to open a connection to the phone, the phone is identified by its name
theError = iPhone.Open(iTelServer, info.iName);
if (theError)
{
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Get info about the first line from the phone
RPhone::TLineInfo lineInfo;
theError = iPhone.GetLineInfo(0, lineInfo);
if (theError)
{
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
// Use this to open a line
theError = iLine.Open(iPhone, lineInfo.iName);
if (theError)
{
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
return theError;
}
return KErrNone;
}
void CActiveClass::ReleasePhone()
{
iLine.NotifyIncomingCallCancel();
iLine.Close();
iPhone.Close();
iTelServer.UnloadPhoneModule(iTsyName);
iTelServer.Close();
}