Read-only archive of the All About Symbian forum (2001–2013) · About this archive

PLEASE HELP , try to hang up an outgoing call

4 replies · 5,090 views · Started 03 January 2005

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();
}

I now use the lineInfo.iNameOfLastCallAdded retrieved with iLine.GetInfo ,
still the call doesnt HangUp - actually nothing happens after I initiate a phone call.

I'm sure that I get to the if(iCallStatus == RCall::EStatusDialling) block .

I did many changes and tests but nothing stopped the call , also tried the DialCancel method ...

Thanks for your help , TE

void CActiveClass::RunL()
{
if (iStatus == KErrNone)
{

if (iCallStatus == RCall::EStatusHangingUp || iCallStatus == RCall::EStatusIdle || iCallStatus == RCall::EStatusUnknown)
{
iCall.Close();
}
else if(iCallStatus == RCall::EStatusDialling)
{
RCall iCall;
RLine::TLineInfo lineInfo;
iLine.GetInfo(lineInfo);
TInt aResult = User::LeaveIfError(iCall.OpenExistingCall(iLine, lineInfo.iNameOfLastCallAdded));
iCall.HangUp();
}
iLine.NotifyStatusChange(iStatus, iCallStatus);
SetActive();
}
}

CActiveClass* CActiveClass::NewL()
{
CActiveClass* self = new (ELeave) CActiveClass();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}

CActiveClass::CActiveClass()
: CActive(0)
{
iLineInited = EFalse;
iCallActive = EFalse;
}

void CActiveClass::ConstructL()
{
User::LeaveIfError(iTimer.CreateLocal());
TRequestStatus aStatus;
iEnv = CEikonEnv::Static();
CActiveScheduler::Add(this);
StartObserver();
}

void CActiveClass::StartObserver()
{
Cancel();
if (InitializePhone() == KErrNone)
{
iLine.NotifyStatusChange(iStatus, iCallStatus);
SetActive();
}
}

TInt CActiveClass::InitializePhone()
{
TInt theError;
if (iLineInited)
{
return KErrNone;
}
theError = iTelServer.Connect();

// Find the number of phones available from the tel server
TInt numberPhones;
theError = iTelServer.EnumeratePhones(numberPhones);

// Read the TSY module name
theError = iTelServer.GetTsyName(0, iTsyName);

// Load in the phone device driver
theError = iTelServer.LoadPhoneModule(iTsyName);

// Get info about the first available phone
RTelServer::TPhoneInfo info;
theError = iTelServer.GetPhoneInfo(0, info);

// Use this info to open a connection to the phone, the phone is identified by its name
theError = iPhone.Open(iTelServer, info.iName);

RPhone::TLineInfo lineInfo;
theError = iPhone.GetLineInfo(0, lineInfo);

theError = iLine.Open(iPhone, lineInfo.iName);

iLineInited = ETrue;
return KErrNone;
}

could this be related to the ownership of the call ?
I checked and the ownership's status is not owned ...
does it metter ?
can this be the reason that I can't hang up the Call ?

Thanks a lot , TE

Update :
the HangUp works on the Nokia 6600 but only when I replace the EStatusDialling to EStatusConnected .
that means that the hang up occures only when the destination phone answers the outgoing call which is not good for my needs .(maybe its good for a broken heart guy who wants to call his ex girlfriend and hang up immediatly 😊)

its like the hang up is not supported at the StatusDialling ...

Any ideas ?