Hello everyone!!
I am making an application that makes a call using MakeCall from CTelephony and need to spend 2 seconds and then terminate the call with hangup.
Is there any way to wait for those 2 seconds?
thank you very much
Hello everyone!!
I am making an application that makes a call using MakeCall from CTelephony and need to spend 2 seconds and then terminate the call with hangup.
Is there any way to wait for those 2 seconds?
thank you very much
If its normal wait try User::After or if it is in an Active Scheduler you can make use of CActiveSchedulerWait.
Hi, I used user::After() and it worked.
now, I want to do this:
TUint n=0;
while(n<5)
{
iCallDialer->DialTheNumber(phoneNumber);
User::After(2000000);
iClientApp->TerminateCall();
n++;
}
but only the call is made once. And I want call and hangup 5 times.
Is the while loop wrong?
Your while loop is executed only once or call is made only once??? While loop looks ok, there might be some issue in your CallDialer.
ok, I checked the while loop and it is well. Then the problem could be CallDialer, I used the function MakeCall from CTelephony. the call can't be done several times??
I'm no expert in symbian so I don´t know what is happening.
Could you help me, please?
I dont think there is any function MakeCall() in CTelephony. You might talking about CTelephony:ialNewCall().
You can make another call after terminating first one. So make sure u are terminating it in your TerminateCall() method.
Have you handeled active request properly, while dialing a call???
ok, DialNewCall, has been a mistake of mine.
if I make this:
iCallDialer->DialTheNumber(phoneNumber);
User::After(2000000);
iClientApp->TerminateCall();
it work. the call is dialed and after two seconds it hangup.
So I believe that the call is terminated well.
But when I put the while, the behavior is similar as if the loop is not.
Show your TerminateCall() method.
I have used the code in wiki "How to terminate call":
#include <e32base.h>
#include <Etel3rdParty.h>
class CClientApp : public CActive
{
private:
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
public:
CClientApp(CTelephony* aTelephony, CTelephony::TCallId aCallId);
void TerminateCall();
private:
void RunL();
void DoCancel();
};
CClientApp::CClientApp(CTelephony* aTelephony, CTelephony::TCallId aCallId)
: CActive(EPriorityStandard),
iTelephony(aTelephony),
iCallId(aCallId)
{
//Constructor
CActiveScheduler::Add(this);
iTelephony = CTelephony::NewL();
}
void CClientApp::TerminateCall()
{
iTelephony->Hangup(iStatus, iCallId);
SetActive();
}
void CClientApp::RunL()
{
if(iStatus==KErrNone)
{
//The call has been terminated successfully;
}
}
void CClientApp:oCancel()
{
iTelephony->CancelAsync(CTelephony::EHangupCancel);
}
Your TerminateCall() method is issuing asynchronous request, so you must wait for completion of request before dialling again.
Make use of CActiveSchedulerWait
Thank you very much for the answers
Where and how can I use CActiveSchedulerWait?
Spend some time in reading Active Objects, after that take any working example which implemented active objects, like this, once check how it is working and then implement your own active object to call a number 5 times (as you are trying to do below).
hello again!
I have tried to implement the function with active objects, but it doesn't work. I don't get errors in the code but the call isn't hung:
file.h
class MHangupObserver
{
public:
virtual void HandleCompleted(TInt aError) = 0;
};
class CFinishCall : public CActive
{
public:
CFinishCall(MHangupObserver& aObserver);
void ConstructL(void);
~CFinishCall();
private:
void TerminateCall();
void RunL();
void DoCancel();
private:
MHangupObserver& iObserver;
CTelephony* iTelephony;
CTelephony::TCallId iCallId;
};
#endif
file.cpp
CFinishCall::~CFinishCall()
{
Cancel();
delete iTelephony;
}
void CFinishCall::ConstructL(void)
{
iTelephony=CTelephony::NewL();
TerminateCall();
}
CFinishCall::CFinishCall(MHangupObserver& aObserver)
:CActive(EPriorityStandard),iObserver(aObserver)
{
CActiveScheduler::Add(this);
}
void CFinishCall::TerminateCall()
{
if(iTelephony && !IsActive())
{
iTelephony->Hangup(iStatus, iCallId);
SetActive();
}
}
void CFinishCall::RunL()
{
iObserver.HandleCompleted(iStatus.Int());
}
void CFinishCall:oCancel()
{
iTelephony->CancelAsync(CTelephony::EHangupCancel);
}
The code post below works. But I need that the while loop works too.
Any help, please?