Discussion Board

Page 1 of 3 123 LastLast
Results 1 to 15 of 38
  1. #1
    Registered User mynick1000's Avatar
    Join Date
    Oct 2007
    Posts
    39
    Hi,

    I am new at symbian programming. I developed an app to observe incoming calls and auto answer them.

    I wrote the code below. It answers the first incoming call automatically and exits without giving any error.

    I want it to re-observe new incoming calls after the first call completed. (Back to the start of the RunL).

    What may be wrong with this code?



    CallObserver.cpp

    void CCallObserver::Start()
    {
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }

    void CCallObserver::Stop()
    {
    Cancel() ;
    }

    void CCallObserver::RunL()
    {
    if(iStatus == KErrNone)
    {
    CTelephony::TCallStatus status = iLineStatus.iStatus;

    if(CTelephony::EStatusRinging == status)
    {
    iTelephony->AnswerIncomingCall(iStatus, iCallId);
    SetActive() ;
    }
    }

    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    MyAppUi.cpp

    CTelephony *telApi = CTelephony::NewL() ;
    callObserver = new (ELeave) CCallObserver( telApi ) ;
    callObserver->Start();

  2. #2
    Registered User mynick1000's Avatar
    Join Date
    Oct 2007
    Posts
    39
    I found the problem that, I call AnswerIncomingCall passing iStatus (asynchronous) and then when I call NotifyChange, I am also passing the same iStatus ie the same Active object. I am not allowed to do this. Only one outstanding request can be made per Active object.

    But I could'nt find the solution, what do I have to use for AnswerIncomingCall as first parameter?

    Please help. Regards.

  3. #3
    Registered User saji_iq's Avatar
    Join Date
    Jun 2006
    Location
    Lahore, Pakistan
    Posts
    162
    try this code , it will work for you.

    TRequestStatus iiStatus;
    iTelephony->AnswerIncomingCall(iiStatus, iCallId);
    User::WaitForRequest(iiStatus);

    there is another way , write you answeicomming call code in a separate thread and communicate with both active objects using callbacks
    Sajid Iqbal
    ASD, Accredited S60 Developer
    [EMAIL]saji.iq@gmail.com[/EMAIL]

  4. #4
    Registered User mynick1000's Avatar
    Join Date
    Oct 2007
    Posts
    39
    Hi saji_iq,

    Thanks for the response. I have changed the code like below. Now it does not exit after first call, but still does not answer the next incoming call (ringing).

    Do you have a suggestion for this situation?

    Regards

    Code:
    void CCallObserver::Start()
    { 
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    
    void CCallObserver::Stop()
    {
    Cancel() ;
    }
    
    void CCallObserver::RunL()
    {
    if(iStatus == KErrNone)
    {
    CTelephony::TCallStatus status = iLineStatus.iStatus;
    
    if(CTelephony::EStatusRinging == status)
    {
    TRequestStatus iiStatus;
    iTelephony->AnswerIncomingCall(iiStatus, iCallId);
    User::WaitForRequest(iiStatus);
    SetActive() ;
    }
    }
    
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }

  5. #5
    Nokia Developer Moderator ltomuta's Avatar
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,335
    Quote Originally Posted by saji_iq View Post
    try this code , it will work for you.

    TRequestStatus iiStatus;
    iTelephony->AnswerIncomingCall(iiStatus, iCallId);
    User::WaitForRequest(iiStatus);

    there is another way , write you answeicomming call code in a separate thread and communicate with both active objects using callbacks
    Never use User::WaitForRequest() in conjunction with CTelephony.. See TSS000374

    Quote Originally Posted by mynick1000 View Post
    Hi saji_iq,

    Thanks for the response. I have changed the code like below. Now it does not exit after first call, but still does not answer the next incoming call (ringing).

    Do you have a suggestion for this situation?

    Regards

    Code:
    void CCallObserver::Start()
    { 
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    
    void CCallObserver::Stop()
    {
    Cancel() ;
    }
    
    void CCallObserver::RunL()
    {
    if(iStatus == KErrNone)
    {
    CTelephony::TCallStatus status = iLineStatus.iStatus;
    
    if(CTelephony::EStatusRinging == status)
    {
    TRequestStatus iiStatus;
    iTelephony->AnswerIncomingCall(iiStatus, iCallId);
    User::WaitForRequest(iiStatus);
    SetActive() ;
    }
    }
    
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    Never use User::WaitForRequest() inside of an active object.

  6. #6
    Registered User mynick1000's Avatar
    Join Date
    Oct 2007
    Posts
    39
    Thanks for the warning Itomuta,

    Now I have removed the WaitForRequest(iiStatus) part from the code.

    Can I use this code in a way to answer incoming call without exiting after answering the initial incoming call and continues working?

    Scenario is like this :

    1. Observe incoming call
    1. Answer incoming call
    2. Make conversation
    3. Hangup the call
    4. Observe new incoming call
    5. Answer it ...

  7. #7
    Registered User saji_iq's Avatar
    Join Date
    Jun 2006
    Location
    Lahore, Pakistan
    Posts
    162
    Of course it is not recmended to use waitforrequest in an active object , instead use another object where needed, cos waitforrequest make the asynchrouns call to synchornous and that is not good and will create problems,
    Sajid Iqbal
    ASD, Accredited S60 Developer
    [EMAIL]saji.iq@gmail.com[/EMAIL]

  8. #8
    Registered User mynick1000's Avatar
    Join Date
    Oct 2007
    Posts
    39
    Hi,

    Now I try to use two active objects, one for observing incoming calls and other events, and one for answering the incoming call. I have changed the code like below. But when app gets a call, phone reboots. I read lots of threads and some docs, but I couldn't manage it.

    Please help me answering calls without exting.

    Regards, thanks.



    CallObserver.cpp

    Code:
    void CCallObserver::Start()
    { 
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    
    void CCallObserver::Stop()
    {
    Cancel() ;
    }
    
    void CCallObserver::RunL()
    {
    if(iStatus == KErrNone)
    {
    CTelephony::TCallStatus status = iLineStatus.iStatus;
    
    if(CTelephony::EStatusRinging == status)
    {
    AnswerCall(}
    }
    
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    
    void CCallObserver::AnswerCall()
    {
    callAnswer = new (ELeave) CAnswerCall( iTelephony ) ;
    callAnswer->AnswerCall() ;
    }
    AnswerCall.cpp

    Code:
    #include "AnswerCall.h"
    
    CAnswerCall::CAnswerCall(CTelephony* aTelephony)
        : CActive(EPriorityStandard),
          iTelephony(aTelephony)
    {
        //default constructor
    }
    
    void CAnswerCall::AnswerCall()
    {
        iTelephony->AnswerIncomingCall(iStatus, iCallId);
        SetActive();
    }
    
    void CAnswerCall::RunL()
    {
        if(iStatus==KErrNone)
           {} // The call has been answered successfully;
    }
    
    void CAnswerCall::DoCancel()
    {
        iTelephony->CancelAsync(CTelephony::EAnswerIncomingCallCancel);
    }

  9. #9
    Registered User mynick1000's Avatar
    Join Date
    Oct 2007
    Posts
    39
    Hi again,

    I have removed iTelephony->AnswerIncomingCall(iStatus, iCall) function and discovered that app still exits. The problem is not about AnswerIncomingCall function.

    I run the code below. If a call comes, it shows the "EStatusRinging" dialog and exits. Phone continues ringing as expected.

    What may cause the exiting?

    Regards...


    Code:
    void CCallObserver::Start()
    { 
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }
    
    void CCallObserver::Stop()
    {
    Cancel() ;
    }
    
    void CCallObserver::RunL()
    {
    if(iStatus == KErrNone)
    {
    CTelephony::TCallStatus status = iLineStatus.iStatus;
    
    if(CTelephony::EStatusRinging == status)
    {
    TBuf <20> lTest = _L("EStatusRinging") ;
    CEikonEnv::Static()->AlertWin(lTest);
    SetActive() ;
    }
    else if(CTelephony::EStatusConnecting == status)
    {
    TBuf <20> lTest = _L("EStatusConnecting") ;
    CEikonEnv::Static()->AlertWin(lTest);
    SetActive() ;
    }
    else if(CTelephony::EStatusConnected == status)
    {
    TBuf <20> lTest = _L("EStatusConnected") ;
    CEikonEnv::Static()->AlertWin(lTest);
    SetActive() ;
    }
    
    TBuf <20> lTest = _L("next notification request") ;
    CEikonEnv::Static()->AlertWin(lTest);
    
    iTelephony->NotifyChange( iStatus, CTelephony::EVoiceLineStatusChange, iLineStatusPckg );
    SetActive();
    }

  10. #10
    Registered User kis_spn's Avatar
    Join Date
    Feb 2007
    Location
    India
    Posts
    1,128
    Hi MyNick,

    I've seen your problem....There are problem due to active objects ..that's why it's exit...try to call handle in this way......

    void CCallListener :: ListenL()
    {
    Cancel();
    iEvent = CTelephony::EVoiceLineStatusChange;
    iTel->NotifyChange(iStatus,iEvent,iLineStatusPckg);
    SetActive();
    }

    void CCallListener :: RunL()
    {
    if(iStatus.Int()!=KErrNone)
    {
    ListenL();
    return;
    }

    switch(iLineStatus.iStatus)
    {
    case CTelephony::EStatusRinging:
    {
    iTel->AnswerIncomingCall( iStatus, iCallId, CTelephony::EVoiceLine );
    SetActive();
    break;
    }
    case CTelephony::EStatusConnected:
    case CTelephony::EStatusAnswering:
    {
    iEvent = CTelephony::EVoiceLineStatusChange;
    iTel->NotifyChange(iStatus, iEvent, iLineStatusPckg);
    SetActive();
    break;
    }
    case CTelephony::EStatusDisconnecting:
    case CTelephony::EStatusIdle:
    {
    //Listen again new Call.....
    ListenL();
    break;
    }
    default:
    {
    iEvent = CTelephony::EVoiceLineStatusChange;
    iTel->NotifyChange(iStatus, iEvent, iLineStatusPckg);
    SetActive();
    break;
    }

    }

    }

    //Use this code, Hope It'll solve your problem.....
    //It's working fine for me......

  11. #11
    Registered User aamitgupta's Avatar
    Join Date
    Jul 2007
    Location
    Noida
    Posts
    1,503
    Hi Mynic

    Yoy are going right , please go through following link, i hope it will very use full in CTelephony for dia, answer, and many more operations.

    http://developer.uiq.com/devlib/uiq_...ony/index.html

    with best Regards
    Amit

  12. #12
    Super Contributor paipeng's Avatar
    Join Date
    Jun 2005
    Location
    Berlin
    Posts
    721
    Hello, I got the Answer Call working before, but now it doesn't.

    I got the same problem, after answering, the application is crashed.

    I have tried also not through the AnswerIncomingCall function, but by pressing the GREEN answer button manuelly. It crashed, too.

    It looks like the problem on active object [SetActive()]:
    just aftering in RunL():
    case CTelephony::EStatusAnswering: // 4
    RequestNotification(); // crashed after 'SetActive()'

    Can anybody check out the problem reasons?!

    Thanks a lot

    Pai


    Code:
    void CTelephoneEngine::RequestNotification()
    	{
    	LogL(_L("Request Notification\n"));
    iTelephony->NotifyChange(iStatus,CTelephony::EVoiceLineStatusChange,iLineStatusPckg );
    	LogL(_L("SetActive..."));
    	SetActive();
    	}
    and
    Code:
    void CTelephoneEngine::RunL()
    	{
    	//LogL(_L("RunL IN\n"));
    	
        if(iStatus != KErrNone)
        	{
        	// ***********Handle Error here ************
       		LogL(_L("Error by status\n"));
       		TBuf<32> ecode;
       		ecode.Format(_L("ErrorNo: %d\n"), iStatus.Int());
       		LogL(ecode);
       		return;
        	}
        
    	switch (iLineStatus.iStatus)
    		{
    		case CTelephony::EStatusIdle: // 1
    			{
            	LogL(_L("Status: Idle\n"));
            	//iNotifier.TelephoneReadyL();
        		RequestNotification();
    			break;	
    			}
    		case CTelephony::EStatusDialling: // 2
    			{
    			LogL(_L("Status: Dialling\n"));
    			//iNotifier.TelephoneDialingL();
    			RequestNotification();
    			break;
    			}
    		case CTelephony::EStatusRinging: // 3
    			{
            	LogL(_L("Status: Ringing\n"));
    			//AnswerCallL();
    			RequestNotification();
        		break;
    			}
            case CTelephony::EStatusAnswering: // 4
            	{
            	LogL(_L("Status: Answering\n"));
            	//iNotifier.TelephoneAnsweringL();
        		RequestNotification();
            	break;
            	}
            case CTelephony::EStatusConnecting: // 5
            	{
            	LogL(_L("Status: Connecting\n"));
            	//iNotifier.TelephoneConnectingL();
        		RequestNotification();
            	break;
            	}
            case CTelephony::EStatusConnected: // 6
            	{
            	LogL(_L("Status: Connected\n"));
            	//iNotifier.TelephoneConnectedL();
        		RequestNotification();
            	break;
            	}
            case CTelephony::EStatusDisconnecting: // 8
            	{
            	LogL(_L("Status: Disconnecting\n"));
            	//iNotifier.TelephoneCloseL();
    			RequestNotification();
            	break;
            	}
            default:
            	{
            	//LogL(_L("default: wait for notify change!\n"));
            	TBuf<32> sCode;
            	sCode.Format(_L("Status: %d\n"), iLineStatus.iStatus);
            	LogL(sCode);
        		RequestNotification();
            	break;            
            	}
    		}
    		
    	}

  13. #13
    Super Contributor paipeng's Avatar
    Join Date
    Jun 2005
    Location
    Berlin
    Posts
    721
    in DoCancel()
    Code:
    void CTelephoneEngine::DoCancel()
    	{
        //iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
    	LogL(_L("DoCancel..."));
    	
    	TInt error = iTelephony->CancelAsync(CTelephony::EAnswerIncomingCallCancel);
    	if (error != KErrNone)
    		LogErrorL(_L("EAnswerIncomingCallCancel error: "), error);
    	
    	error = iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
    	if (error != KErrNone)
    		LogErrorL(_L("EVoiceLineStatusChangeCancel error: "), error);
    	}
    I don't think the problem on CancelAsync(), because with or without calling the DoCancel() funtion, the problem is same.

  14. #14
    Registered User aamitgupta's Avatar
    Join Date
    Jul 2007
    Location
    Noida
    Posts
    1,503
    What error code raised and what is doing RequestNotification()?
    Regards,
    Amit


    ****"Putting a Smile on other's faces is the essence of true Happiness"****

  15. #15
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    And what is in the log?

Page 1 of 3 123 LastLast

Similar Threads

  1. FEATURE NOT SUPPORTED(-5) WHILE ANSWER THE INCOMING CALL
    By sanjaychavada in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2007-10-26, 12:11
  2. Replies: 3
    Last Post: 2007-10-04, 16:37
  3. how to simulate incoming call event in Emulator?? egent !!
    By wjcrr in forum Series 40 & S60 Platform Feedback Archive
    Replies: 0
    Last Post: 2007-05-11, 03:58
  4. Replies: 1
    Last Post: 2006-03-08, 04:41
  5. Problem in trying to connect to Incoming Call
    By Rajagopalan in forum Symbian C++
    Replies: 10
    Last Post: 2004-09-10, 05:29

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved