×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    13

    My App is terminated

    Hi All,

    I am newbie in Series 60 and SYmbian in general. I have the following problem. I developed a very simple application (copied from the helloworldbasic in SDK). The only difference is that the application is sent to background mode and is waiting for a change in the line. While the application is running and incoming call is performed the application is terminated. My needs are to print a simple information note before receiving the call. How can I achieve it? Here is my code:

    RTelServer server;
    CleanupClosePushL(server);
    User::LeaveIfError(server.Connect());

    User::LeaveIfError(server.LoadPhoneModule(KTsyName));
    TInt numberPhones;
    User::LeaveIfError(server.EnumeratePhones(numberPhones));
    if (numberPhones < 1)
    {
    User::Leave(KErrNotFound);
    }


    RTelServer::TPhoneInfo phoneInfo;
    User::LeaveIfError(server.GetPhoneInfo(0, phoneInfo));


    RPhone phone;
    CleanupClosePushL(phone);

    User::LeaveIfError(phone.Open(server, phoneInfo.iName));
    RPhone::TLineInfo lineInfo;
    User::LeaveIfError(phone.GetLineInfo(0, lineInfo));

    RLine line;
    CleanupClosePushL(line);
    User::LeaveIfError(line.Open(phone, lineInfo.iName));

    TRequestStatus status;
    RCall::TStatus callStatus;

    line.NotifyStatusChange(status, callStatus);

    TApaTask MyApp(iEikonEnv->WsSession());
    MyApp.SetWgId(iEikonEnv->RootWin().Identifier());
    MyApp.SendToBackground();

    User::WaitForRequest(status);
    // to print here
    MyApp.BringToForeground();


    CleanupStack::PopAndDestroy(2);
    User::LeaveIfError(server.UnloadPhoneModule(KTsyName));

    CleanupStack::PopAndDestroy(&server);

  2. #2
    Regular Contributor
    Join Date
    Feb 2005
    Posts
    328
    You problem is here:

    TRequestStatus status;
    RCall::TStatus callStatus;

    line.NotifyStatusChange(status, callStatus);

    TApaTask MyApp(iEikonEnv->WsSession());
    MyApp.SetWgId(iEikonEnv->RootWin().Identifier());
    MyApp.SendToBackground();

    User::WaitForRequest(status); // ***


    This code should be replaced with an active object

    see: CActive

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    13
    Thanks for your reply. I've done what you suggested but I am not still able to make a workable solution. Right now the application doesn't die once an incoming call is received but the problem is that it dies once NotifyStatusChange call is invoked.

    Here is part of my new code:

    void CHelloWorldBasicAppUi:ialL()
    {
    RTelServer server;
    CleanupClosePushL(server);

    User::LeaveIfError(server.Connect());

    User::LeaveIfError(server.LoadPhoneModule(KTsyName));

    RTelServer::TPhoneInfo phoneInfo;
    User::LeaveIfError(server.GetPhoneInfo(0, phoneInfo));


    RPhone phone;
    CleanupClosePushL(phone);

    User::LeaveIfError(phone.Open(server, phoneInfo.iName));
    RPhone::TLineInfo lineInfo;
    User::LeaveIfError(phone.GetLineInfo(0, lineInfo));

    RLine line;
    CleanupClosePushL(line);
    User::LeaveIfError(line.Open(phone, lineInfo.iName));

    callListener->DialL(&line, this);

    CleanupStack::PopAndDestroy(2);

    User::LeaveIfError(server.UnloadPhoneModule(KTsyName));
    CleanupStack::PopAndDestroy(&server);
    }

    callListener is a CActive object and its RunL method is:

    void CCallListener::RunL()
    {

    #if __WINS__

    #else

    RCall::TStatus callStatus;
    CEikonEnv::Static()->AlertWin(_L(" No error 1"));
    iLine->NotifyStatusChange(iStatus, callStatus);
    CEikonEnv::Static()->AlertWin(_L(" No error 2"));
    User::WaitForRequest(iStatus);

    if (iStatus == KErrNone)
    {
    CEikonEnv::Static()->AlertWin(_L(" No error"));
    //iObserver->GoForeground();
    }

    #endif

    //SetActive();
    }

    void CCallListener:ialL(RLine* line, MCallObserver* observer)
    {
    iLine = line;
    iObserver = observer;
    iObserver->GoBackground();
    #if __WINS__

    #else

    SetActive();
    #endif
    }

    Now I receive No Error 1 message but I don't reach No Error 2 message and application terminates.

    Any help will be highly appriciated

  4. #4
    Regular Contributor
    Join Date
    Feb 2005
    Posts
    328
    Here's an example implementation...

    In your CAppUi derived class, add a CCallListener object.
    In your CAppUi::ConstructL() create an instance of it and call Start().

    Once a status change is detected, RLine will 'complete' any active objects waiting for a status change and the RunL will be called.

    In active object programming, don't use User::WaitForRequest()! This will prevent all the other active objects in your thread from running and can lead to a crash. Don't forget that the UI framework is also using AOs...

    //////////////////////////////////////////////////////////

    class CCallListener : public CActive
    {
    public:
    CCallListener* NewL();
    virtual ~CCallListener();
    void Start();
    protected:
    CCallListener();
    void ConstructL();
    public:
    // from CActive
    virtual void RunL();
    virtual void DoCancel();
    private:
    RCall::TStatus iCallStatus;
    //
    RTelServer iServer;
    RPhone iPhone;
    RLine iLine;
    };

    //////////////////////////////////////////////////////////

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

    CCallListener::CCallListener() : CActive(0)
    {
    }

    CCallListener::~CCallListener()
    {
    Cancel();
    iLine.Close();
    iPhone.Close();
    iServer.UnloadPhoneModule(KTsyName);
    iServer.Close();
    }

    void CCallListener::Start()
    {
    TApaTask MyApp(iEikonEnv->WsSession());
    MyApp.SetWgId(iEikonEnv->RootWin().Identifier());
    MyApp.SendToBackground();

    iLine.NotifyStatusChange(iStatus, iCallStatus);
    SetActive();
    }

    void CCallListener::ConstructL()
    {
    // connect to server
    User::LeaveIfError(iServer.Connect());
    User::LeaveIfError(iServer.LoadPhoneModule(KTsyName));
    TInt numberPhones;
    User::LeaveIfError(iServer.EnumeratePhones(numberPhones));
    if (numberPhones < 1)
    {
    User::Leave(KErrNotFound);
    }

    // open phone
    RTelServer::TPhoneInfo phoneInfo;
    User::LeaveIfError(iServer.GetPhoneInfo(0, phoneInfo));
    User::LeaveIfError(iPhone.Open(server, phoneInfo.iName));
    RPhone::TLineInfo lineInfo;

    // open line
    User::LeaveIfError(iPhone.GetLineInfo(0, lineInfo));
    User::LeaveIfError(iLine.Open(phone, lineInfo.iName));

    CActiveScheduler::Add(this);
    }

    void CCallListener::RunL()
    {
    // you probably want to check iCallStatus here...
    TApaTask MyApp(iEikonEnv->WsSession());
    MyApp.SetWgId(iEikonEnv->RootWin().Identifier());
    MyApp.BringToForeground();
    }

    void CCallListener:oCancel()
    {
    iLine.CancelNotifyStatusChange();
    }

Posting Permissions

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