Detecting Calls and Answering - CTelephony Symbian 9.1 S60 3rd Edition

Login to reply to this topic.
Sun, 2008-06-15 12:43
Joined: 2008-06-15
Forum posts: 41

Hello to you all .

I am a newbie to Mobile Developing .
I am Using Carbide.C++ 1.3 , FP1.2 , for symbiam OS , using N95 as phone platform.
I am trying to build and application that will catch an outgoing call , save the number , call another number and send the original number as DTMF . I searched the forums for answers but non were found.
I wrote a class called Engine who will lsten on events regarding EVOICELINE.
it will be on creation as UNKNOWN an listen to changes using NotifyChange();
in the method RunL() i put in the code which will be executed on change :
1.If phone rings - answer the call.
2.If phone dials outgoing number - Save number , hang up , dial the new number (A.K.A service number) and if connection is good send as DTMF and hang up again.

For some reason , it wont do as written Smiling
I have no idea why , i wanted to check if it answers the phone automatically , it won't .
what can be the problem ?

should i seperate each desired operation to a seperate active class ?

(No GUI code is inserted of course)

//HEADER FILE

#ifndef ENGINE_H
#define ENGINE_H

#include <e32base.h>        // For CActive, link against: euser.lib
#include <Etel3rdParty.h>


_LIT(serviceNum,"+97297883450");

class CEngine : public CActive
{
public:
        // Cancel and destroy
        ~CEngine();

        // Two-phased constructor.
        static CEngine* NewL();

        // Two-phased constructor.
        static CEngine* NewLC();

public: // New functions
        // Function for making the initial request
        void StartEngine();


private:
        // C++ constructor
        CEngine();
       
       
        // Second-phase constructor
        void ConstructL();
       
       
       
private: // From CActive
        // Handle completion
        void RunL();
       
        // How to cancel me
        void DoCancel();
       
        // Override to handle leaves from RunL(). Default implementation causes
        // the active scheduler to panic.
        TInt RunError( TInt aError );

private:
    CTelephony* iTelephony;
   
    CTelephony::TRemotePartyInfoV1 iRemInfoUse;
        CTelephony::TCallInfoV1                   iCallInfoUse;
        CTelephony::TCallSelectionV1   iCallSelectionUse;

        CTelephony::TRemotePartyInfoV1Pckg         iRemParty;
        CTelephony::TCallInfoV1Pckg                 iCallInfo;
        CTelephony::TCallSelectionV1Pckg         iCallSelection;

        CTelephony::TCallStatusV1 iCallStatus;
        CTelephony::TCallStatusV1Pckg iCallStatusPkg;
        CTelephony::TCallId iCallId;

       
};

//SOURCE FILE

#include "Engine.h"
#include <e32base.h>
#include <EIKENV.H>
#include <aknnotewrappers.h>



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

CEngine::CEngine() : CActive( EPriorityHigh ),        // Standard priority                                                                       
                                                               iRemParty(iRemInfoUse),
                                                               iCallInfo(iCallInfoUse),
                                                               iCallSelection(iCallSelectionUse),
                                                               iCallStatusPkg(iCallStatus)       
        {
        iCallStatus.iStatus = CTelephony::EStatusUnknown;
        }

void CEngine::ConstructL()
        {
        iTelephony = CTelephony::NewL();
       
        CActiveScheduler::Add( this );
        }

CEngine::~CEngine()
        {
                Cancel();
                if (iTelephony)
        {
        delete iTelephony;
        iTelephony = NULL;
        }
        }

void CEngine::DoCancel()
        {
        iTelephony->CancelAsync(CTelephony::EVoiceLineStatusChangeCancel);
        }


void CEngine::StartEngine()
        {
       
        iTelephony->NotifyChange(iStatus, CTelephony::EVoiceLineStatusChange, iCallStatusPkg);
    SetActive();
        }

void CEngine::RunL()
{   
    if(iStatus==KErrNone)
            {
                      
            CTelephony::TCallStatus status = iCallStatus.iStatus;
              
              
               switch ( status )
                                 {
                                         case CTelephony::EStatusRinging:
                                                 {
                                                

                                                iTelephony->AnswerIncomingCall(iStatus,iCallId,CTelephony::EVoiceLine);
                                               
                                                }
                                          break;
                                 
                           
                                     case CTelephony::EStatusDialling:
                                             {
                                             iCallSelectionUse.iLine = CTelephony::EVoiceLine;
                                             iCallSelectionUse.iSelect = CTelephony::EInProgressCall;
                                             iTelephony->GetCallInfo(iCallSelection,iCallInfo,iRemParty);
                                    iTelephony->Hangup(iStatus,iCallId);
                                   
                                    TBuf8<100> CallerNumber;
                                    CallerNumber.Copy(iRemInfoUse.iRemoteNumber.iTelNumber);
                                    CallerNumber.Append('#');
                                                                      
                                    CTelephony::TTelNumber telNumber(serviceNum);
                                       CTelephony::TCallParamsV1 callParams;
                                       callParams.iIdRestrict = CTelephony::ESendMyId;
                                       CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);

                                       iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
                                      
                                   
                                   
                                    }
                            break;       
                                                           
                                  }
                              
                               iTelephony->NotifyChange( iStatus,
                              CTelephony::EVoiceLineStatusChange,
                              iCallStatusPkg );
                               SetActive();
                 }
             
        }

TInt CEngine::RunError( TInt aError )
{
        return aError;
}

Thank you in advance!!!!


Wed, 2008-06-18 16:17
Joined: 2007-11-14
Forum posts: 10
Re: Detecting Calls and Answering - CTelephony Symbian 9.1 S60 3

My only thought would be that you could want to listen for changes on something other than the VoiceLine (which may only change when the call is answered, rather than when the call is incoming). My best guess as to what you would want is EOwnedCall1StatusChange and EOwnedCall2StatusChange, but I'm not sure. Best bet is to play around with what you are listening for Smiling

Sun, 2008-06-22 07:27
Joined: 2008-06-15
Forum posts: 41
FOLLOW UP ON QUESTION

Well , is it true that i cant listen to calls that i don't own?

  • Login to reply to this topic.