×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    17

    Dial a Call Console Problem

    Hello everybody,

    Im new in programming with c++ for symbian. And sorry for my bad english, i'll try to do my best ;-)

    Now to my problem:
    I try to dial a call from a console. First my code:

    The mainclass:
    Code:
    #include "CallTest.h"
    #include <e32base.h>
    #include <e32std.h>
    #include <e32cons.h>			// Console
    #include "MakeCall.h"
    
    //  Constants
    _LIT(KTextConsoleTitle, "Console");
    _LIT(KTextFailed, " failed, leave code = %d");
    _LIT(KTextPressAnyKey, " [press any key]\n");
    //  Global Variables
    LOCAL_D CConsoleBase* console; // write all messages to this
    //  Local Functions
    
    LOCAL_C void MainL()
    	{
    	console->Write(_L("Start Call\n"));
    	CDemoInstance* demo = new(ELeave)CDemoInstance;
    	demo->DialPhoneByCTelephony(_L("012345678"));
    	
    	CActiveScheduler::Start();
    	console->Write(_L("Stop Call\n"));
    	delete demo;
    	}
    
    LOCAL_C void DoStartL()
    	{
    	// Create active scheduler (to run active objects)
    	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
    	CleanupStack::PushL(scheduler);
    	CActiveScheduler::Install(scheduler);
    
    	MainL();
    
    	// Delete active scheduler
    	CleanupStack::PopAndDestroy(scheduler);
    	}
    
    //  Global Functions
    
    GLDEF_C TInt E32Main()
    	{
    	// Create cleanup stack
    	__UHEAP_MARK;
    	CTrapCleanup* cleanup = CTrapCleanup::New();
    
    	// Create output console
    	TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));
    	if (createError)
    	return createError;
    
    	// Run application code inside TRAP harness, wait keypress when terminated
    	TRAPD(mainError, DoStartL());
    	if (mainError)
    	console->Printf(KTextFailed, mainError);
    	console->Printf(KTextPressAnyKey);
    	console->Getch();
    	
    	delete console;
    	delete cleanup;
    
    	__UHEAP_MARKEND;
    	return KErrNone;
    	}
    MakeCall.cpp:

    Code:
    #import "MakeCall.h"
    
    CDemoInstance::CDemoInstance()
    {
        // No implementation required
    }
    
    CDemoInstance::~CDemoInstance()
    {
    
    }
    
    void CDemoInstance::DialPhone(const TDesC& aMdn)
    {
        
    }
    
    void CDemoInstance::DialPhoneByCTelephony(const TDesC& aMdn)
    {
        iCallDialer = new (ELeave)CCallDialer(*this);
        iCallDialer->ConstructL(aMdn);
    }
    
    void CDemoInstance::CallDialedL(TInt aError)
    {
        delete iCallDialer;
        iCallDialer = NULL;
    }
    
    CCallDialer::~CCallDialer()
    {
        Cancel();
        delete iTelephony;
    }
    
    void CCallDialer::ConstructL(const TDesC& aNumber)
    {
        iTelephony = CTelephony::NewL();
        CTelephony::TTelNumber telNumber(aNumber);
    
        CTelephony::TCallParamsV1 callParams;
        callParams.iIdRestrict = CTelephony::ESendMyId;
        CTelephony::TCallParamsV1Pckg callParamsPckg(callParams);
    
        iTelephony->DialNewCall(iStatus, callParamsPckg, telNumber, iCallId);
        SetActive();
    }
    
    CCallDialer::CCallDialer(MDialObserver& aObserver)
    : CActive(EPriorityHigh),iObserver(aObserver)
    {
        CActiveScheduler::Add(this);
    }
    
    void CCallDialer::RunL()
    {
        iObserver.CallDialedL(iStatus.Int());
        CActiveScheduler::Stop();
    }
    
    void CCallDialer::DoCancel()
    {
        iTelephony->CancelAsync(CTelephony::EDialNewCallCancel);
    }
    MakeCall.h:
    Code:
    #include <Etel3rdParty.h>
    #include <etel.h>
    // link to etel3rdparty.lib
    
    class MDialObserver
    {
    public:
        virtual void CallDialedL(TInt aError) = 0;
    };
    class CCallDialer;
    
    class CDemoInstance : public CBase, public MDialObserver
    {
    public:
        void DialPhone(const TDesC& aMdn);
        void DialPhoneByCTelephony(const TDesC& aMdn);
    public:
        virtual void CallDialedL(TInt aError);
    public:
        ~CDemoInstance();
        CDemoInstance();
        CCallDialer* iCallDialer;
    };
    class CCallDialer : public CActive
    {
    public:
        CCallDialer(MDialObserver& aObserver);
        void ConstructL(const TDesC& aNumber);
        ~CCallDialer();
    private:
        void RunL();
        void DoCancel();
    private:
        MDialObserver&             iObserver;
        CTelephony*                iTelephony;
        CTelephony::TCallId      iCallId;
    };
    The Problem:
    The Emulator only makes an Etel Server 1 panic. So i try this on an N95. There the output on the console is only: "Start Call\n Stop Call" without doing anything else! Why? Where im wrong?
    I search a lot but dont find an answer. All examples uses a GUI :-(

    I use S60 3rd Edition SDK FP2

    Please help me..
    Thank you!

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Dial a Call Console Problem

    i suggest CActiveScheduler::Start();

    before you do any thing.

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,734

    Re: Dial a Call Console Problem

    CActiveScheduler::Start seems to be already in its place.

    When you issue an asynchronous request, it is 'preferred' (so it is a rule) to have all arguments accessible until the request completes. So move CTelephony::Xy (TTelNumber, CallParams) to member variables of CCallDialer.

    A slight comment: note that N95 is an S60 3rd editon FP1 device. In this particular case your code will probably work, but generally it is better to have a fully compatible SDK.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Noida, India
    Posts
    150

    Re: Dial a Call Console Problem

    what about capabilities in your console? have u defined required capabilities in mmp??

  5. #5
    Registered User
    Join Date
    Jul 2008
    Posts
    17

    Re: Dial a Call Console Problem

    thanks for your answers.

    With CActiveScheduler::Start(); before demo->DialPhoneByCTelephony(_L("012345678")); the console will stop and crash.
    I move TTelNumber, CallParams to the member Variabels but nothing change

    I've defined the "NetworkServices" in the capabilities. Need something else?

    It dont work yet :-(

    EDIT: yeeeaaaaaaaaaaah it works!!! i did nothing but works fine ;-)
    Thank you for your help, youre the best!
    Last edited by Ceratos; 2008-07-18 at 10:03.

Similar Threads

  1. Replies: 7
    Last Post: 2011-06-02, 11:35
  2. Replies: 3
    Last Post: 2008-05-21, 12:40
  3. Call Log Problem
    By pavan in forum Symbian
    Replies: 6
    Last Post: 2007-01-04, 14:30
  4. HELP - RCall - Dial voice number crash
    By cmryan in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2004-02-13, 14:53
  5. Replies: 1
    Last Post: 2002-08-28, 09:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×