×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67

    How to get control to my aap after disconnecting a call

    Hi
    I had made a DialNumberL function which makes a call and after the calls end , i want the control to return back to my app. Can u guide my way through.


    My code goes like this...

    void CEmbedDemoContainer2:ialNumberL(const TDesC& aPhoneNumber)
    {
    _LIT (KTsyName,"phonetsy.tsy");

    //Create a connection to the tel server
    RTelServer server;
    CleanupClosePushL(server);
    User::LeaveIfError(server.Connect());

    //Load in the phone device driver
    User::LeaveIfError(server.LoadPhoneModule(KTsyName));

    //Find the number of phones available from the tel server
    TInt numberPhones;
    User::LeaveIfError(server.EnumeratePhones(numberPhones));

    //Check there are available phones
    if (numberPhones < 1)
    {
    User::Leave(KErrNotFound);
    }

    //Get info about the first available phone
    RTelServer::TPhoneInfo info;
    User::LeaveIfError(server.GetPhoneInfo(0, info));

    //Use this info to open a connection to the phone, the phone is identified by its name
    RPhone phone;
    CleanupClosePushL(phone);
    User::LeaveIfError(phone.Open(server, info.iName));

    //Get info about the first line from the phone
    RPhone::TLineInfo lineInfo;
    User::LeaveIfError(phone.GetLineInfo(0, lineInfo));

    //Use this to open a line
    RLine line;
    CleanupClosePushL(line);
    User::LeaveIfError(line.Open(phone, lineInfo.iName));

    //Open a new call on this line
    TBuf <100> newCallName;
    RCall call;
    CleanupClosePushL(call);
    User::LeaveIfError(call.OpenNewCall(line, newCallName));

    //newCallName will now contain the name of the call
    User::LeaveIfError(call.Dial(aPhoneNumber));

    //Close the phone, line and call connections and remove them from the cleanup stack
    //NOTE: This does not hang up the call
    CleanupStack::PopAndDestroy(3);//phone, line, call

    TApaTask task(CEikonEnv::Static()->WsSession());
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task.BringToForeground();
    //Unload the phone device driver

    /* RCall::TStatus iCallStatus;
    if (iCallStatus == call.EStatusHangingUp || call.EStatusUnknown)
    {
    TApaTask task(CEikonEnv::Static()->WsSession());
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task.BringToForeground();
    }
    */

    //User::LeaveIfError(server.UnloadPhoneModule(KTsyName));
    TInt k=0;
    k=server.UnloadPhoneModule(KTsyName);
    if( k!= KErrNone )
    {
    TApaTask task(CEikonEnv::Static()->WsSession());
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task.BringToForeground();
    }
    //Close the connection to the tel server and remove it from the cleanup stack
    CleanupStack::PopAndDestroy(&server);


    }



    I dont know exactly what i m supposed to do .


    Alok

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    you should wrap the whole thing into a active object and then when the call is established, you just start notifier that will call your RunL back when the call status changes, then you'll just acta ccordingly there.

    yucca

  3. #3
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67

    My code using active object

    Hi Yucca,
    i had wrap my make call code in active object, just have a look, i m doing everything right or not.
    my code goes like this....

    #include <etel.h>
    #include <apgtask.h >
    #include <embeddemoappui.h>





    class CActiveCall : public CActive
    {
    public:
    CActiveCall();
    void ConstructL();
    ~CActiveCall();
    void DialNumber(TDesC* aPhoneNumber);
    void DoCancel();
    void RunL();
    private:
    RCall* call;
    RTelServer* server;
    TBuf <100> newCallName;
    };

    CActiveCall::CActiveCall(): CActive(CActive::EPriorityHigh)
    // Construct high-priority active object
    {
    __DECLARE_NAME(_S("CActiveCall"));
    }

    void CActiveCall::ConstructL()
    {
    // Add to active scheduler
    CActiveScheduler::Add(this);
    }

    CActiveCall::~CActiveCall()
    {
    // Make sure we're cancelled
    Cancel();
    }

    void CActiveCall:oCancel()
    {
    // need to check for call and cancel
    }

    void CActiveCall::RunL()
    {
    }

    void CActiveCall:ialNumber(TDesC* aPhoneNumber)
    {
    _LIT (KTsyName,"phonetsy.tsy");
    _LIT (iNumber,"989102304");
    RTelServer::TPhoneInfo info;
    RPhone::TLineInfo lineInfo;

    // Connect to the telephony server and load the TSY.
    server = new (ELeave) RTelServer;
    User::LeaveIfError(server->Connect());
    User::LeaveIfError(server->LoadPhoneModule(KTsyName));

    // Get the details for the first (and only) phone.
    User::LeaveIfError(server->GetPhoneInfo(0, info));

    // Open the phone.
    RPhone phone;
    CleanupClosePushL(phone);
    User::LeaveIfError(phone.Open(*server, info.iName));

    // Get the information for the voice line, line 0.
    User::LeaveIfError(phone.GetLineInfo(0, lineInfo));

    // Open the line. iName will now be "VoiceLine1".
    RLine line;
    CleanupClosePushL(line);
    User::LeaveIfError(line.Open(phone, lineInfo.iName));

    // Open a new phone call.
    call = new (ELeave) RCall;

    User::LeaveIfError(call->OpenNewCall(line, newCallName));
    TRAPD(error,call->Dial(iNumber));//

    CleanupStack::PopAndDestroy(2);//phone, line

    TApaTask task1(CEikonEnv::Static()->WsSession());
    task1.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task1.BringToForeground();

    if(server)
    User::LeaveIfError(server->UnloadPhoneModule(KTsyName));

    delete call;
    call = NULL;
    delete server;
    server = NULL;

    SetActive();
    }

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    I think you dont have too much idea of how the active objects work, so I would suggest you to go to www.symbian.com and locate the paper written by Mr. Martin Tasker, it explains the main features and usage of active objects quite nicely.

    yucca

  5. #5
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67

    How to intiate the active class from container

    Hi yucca,
    i had gone through the active object and now my code goes like this..


    #include <etel.h>
    #include <embeddemoappui.h>

    class RCall;

    class CActiveDial : public CActive
    {
    public:
    CActiveDial();
    void ConstructL();
    ~CActiveDial();
    void DialNumber();
    void DoCancel();
    void RunL();

    private:
    TBuf16<60> phoneNoBuf;
    RCall* call;
    RTelServer* server;
    TBuf <100> newCallName;
    RCall::TStatus aStatus;
    RCall iPhoneCall;
    //TBuf8<40> aStatus;
    };




    CActiveDial::CActiveDial(): CActive(CActive::EPriorityHigh)
    // Construct high-priority active object
    {
    __DECLARE_NAME(_S("CActiveDial"));
    }

    void CActiveDial::ConstructL()
    {
    // Add to active scheduler
    CActiveScheduler::Add(this);
    }

    CActiveDial::~CActiveDial()
    {
    // Make sure we're cancelled
    Cancel();
    }

    void CActiveDial:oCancel()
    {
    // need to check for call and cancel
    }

    void CActiveDial::RunL()
    {

    if(iStatus.Int()==KErrNone)
    {
    RCall::TStatus callStatus;
    iPhoneCall.GetStatus(callStatus);
    switch (callStatus)
    {
    case RCall::EStatusConnected:
    {
    TApaTask task(CEikonEnv::Static()->WsSession());
    task.SetWgId(CEikonEnv::Static()->RootWin().Identifier());
    task.BringToForeground();
    }
    }
    }
    }




    void CActiveDial:ialNumber()
    {
    _LIT (KTsyName,"phonetsy.tsy");
    // _LIT (iNumber,"989102304");
    RTelServer::TPhoneInfo info;
    RPhone::TLineInfo lineInfo;

    // Connect to the telephony server and load the TSY.
    server = new (ELeave) RTelServer;
    User::LeaveIfError(server->Connect());
    User::LeaveIfError(server->LoadPhoneModule(KTsyName));

    // Get the details for the first (and only) phone.
    User::LeaveIfError(server->GetPhoneInfo(0, info));

    // Open the phone.
    RPhone phone;
    CleanupClosePushL(phone);
    User::LeaveIfError(phone.Open(*server, info.iName));

    // Get the information for the voice line, line 0.
    User::LeaveIfError(phone.GetLineInfo(0, lineInfo));

    // Open the line. iName will now be "VoiceLine1".
    RLine line;
    CleanupClosePushL(line);
    User::LeaveIfError(line.Open(phone, lineInfo.iName));

    // Open a new phone call.
    call = new (ELeave) RCall;


    HBufC* iNumber = HBufC::NewLC(200);
    iNumber->Des().Copy(phoneNoBuf);

    User::LeaveIfError(call->OpenNewCall(line, newCallName));
    //TRAPD(error,call->Dial(*iNumber));
    TRAPD(error,call->Dial(iStatus,*iNumber)); //call dial with status

    SetActive();
    CleanupStack::PopAndDestroy(2);//phone, line
    if(server)
    User::LeaveIfError(server->UnloadPhoneModule(KTsyName));

    delete call;
    call = NULL;
    delete server;
    server = NULL;

    // SetActive();
    }

    first tell me that whether now i m doing right, and secondly i want to know that, i f want to make a call when some event occur on my listbox in container class. So how can i intiate the active class from my container class on some event.

    Plaese guide my way through.
    Alok

  6. #6
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    looks a lot better now already, anyway for monitoring the phone call (for example for hang-up) you could use NotifyStatusChange()-fucntion of the RCall after the call have dialed.

    for observing events in other components, you should always check the sdk docs & headers for function that is used for setting a observer. For example listbox has SetListBoxObserver()-function. Then check the observer interface definitions and implement the required functions in your container (observer) class.

    yucca

  7. #7
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67

    Intiate the active class from container

    Hi Yucca,
    I had no problem in trapping the event in listbox , i m trapping the event of listbox and opening different views.
    But now my problem is, I m not able to intiate the code written in my active class, that is CActiveDial class which i had given in my previous post .
    From my container class, i m not able to call any function of this CActiveDial class.

    Please guide me, I know i m troubling u a lot.
    Thanks

    Alok

  8. #8
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143
    can't really understand the problem. could you be a bit more specific and explain a bit moe of why you are not able to call any function defined in your active object ?

    What happens ? and when (compiling, running etc ) ?

    yucca

  9. #9
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67
    I am creating the object of the CActiveDial class in my contructor of container class and then calling the DialNumber() function when i trapped the event of my listbox in OfferKeyEventL() function but at compile time it gives error, no default contructor available ,i dont know where i m doing wrong.

    Alok

  10. #10
    Regular Contributor
    Join Date
    Mar 2004
    Location
    India
    Posts
    67
    Hi Yucca,
    this question is not related to my previous post,
    I had installed a sis file on my device , while my app runs on device it creates to file on C drive, which i uses while my app is running. Now i want that when i unistall my app , i want to delete those two file also from my device.
    Can u plaese guide me , how to acheive that.

    thanks

    alok.

Posting Permissions

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