×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Ukraine
    Posts
    56

    CTelephony (CActive) didn't invoke RunL()

    Hi there,

    I have implemented CellId monitor
    but one problem remains

    I call assinchronous function and SetActive()
    But RunL never invokes

    I wait few hour but it didn't help

    Please, explain me what I am doing wrong
    I work with active objects befor and I implement it in the same way
    here is my code:
    Code:
    class MNetworkObserver
    {
    public:
       virtual void OperationFinished(const TDes & aBuf) = 0;
    };
    
    class CNetworkInfo :public CActive
    {
    public:
    	static CNetworkInfo * NewLC(MNetworkObserver & aObserver);
    	static CNetworkInfo * NewL(MNetworkObserver & aObserver);
    	virtual ~CNetworkInfo();
    
    	void Process();
    
    private:
    	CNetworkInfo(MNetworkObserver & aObserver);
    
    protected:
    	virtual void RunL();
    	virtual void DoCancel();
    	MNetworkObserver & iObserver;
    	CTelephony* iTelephony;
    	CTelephony::TNetworkInfoV1 iNetworkInfoV1;
    	CTelephony::TNetworkInfoV1Pckg iNetworkInfoV1Pckg;
    	TBuf<500> iBuf;
    };
    and cpp
    Code:
    	CNetworkInfo::CNetworkInfo(MNetworkObserver & aObserver)
                           :CActive(0),
    		        iObserver(aObserver), 
                            iNetworkInfoV1Pckg(iNetworkInfoV1)
    		{
    		CActiveScheduler::Add(this);
    		};
    
    	CNetworkInfo::~CNetworkInfo()
    		{
    		Cancel();
    		delete iTelephony;
    		}
    		
    /***************************************
    *
    *   This code never occur, who can explain me why?
    *
    ****************************************/
    	void CNetworkInfo::RunL() // never occur, why?
    		{
    		TInt stat = iStatus.Int();
    		if (stat == KErrNone)
    			{
    		    iBuf.AppendFormat(_L("Name [%S]\n"),&iNetworkInfoV1.iLongName);
    		    iBuf.AppendFormat(_L("LAC    [%d]\n"),iNetworkInfoV1.iLocationAreaCode );
    		    iBuf.AppendFormat(_L("CELLID [%d]\n"),iNetworkInfoV1.iCellId );
    		    iBuf.AppendFormat(_L("CountryCode [%S]\n"),&iNetworkInfoV1.iCountryCode); 
    		    iBuf.AppendFormat(_L("NetworkID [%S]\n"),&iNetworkInfoV1.iNetworkId); 
    			}
    		else 
    			{
    			iBuf.Zero();
    			iBuf.AppendFormat(_L("Error [%d]"), stat);
    			}
    		iObserver.OperationFinished(iBuf);
    		}
    		
    	CNetworkInfo * CNetworkInfo::NewL(MNetworkObserver & aObserver)
    	{
    		CNetworkInfo * self = NewLC(aObserver);
    		CleanupStack::PopAndDestroy(self);
    		return self;
    	}
    
    	CNetworkInfo * CNetworkInfo::NewLC(MNetworkObserver & aObserver)
    	{
    		CNetworkInfo * self = new (ELeave)CNetworkInfo(aObserver);
    		CleanupStack::PushL(self);
    		return self;
    	}
    	void CNetworkInfo::DoCancel()
    		{
    		iTelephony->CancelAsync(CTelephony::EGetCurrentNetworkInfoCancel);
    		};
    
    	void CNetworkInfo::Process()
    		{
    		if (!iTelephony)
    			{
    			iTelephony = CTelephony::NewL();
    			}
    		
    	    if (IsActive()) Cancel();
    
    	    iTelephony->NotifyChange( iStatus,
    	                              CTelephony::ECurrentNetworkInfoChange,
    	                              iNetworkInfoV1Pckg );
    	    SetActive();
    		};
    I invoke this from my CEngine
    like
    Code:
    	if (!iNetworkInfo)
    		{
    		iNetworkInfo = CNetworkCellMonitor::NewL(*this);
                    iNetworkInfo->Process();
    		}
    Last edited by sashaslonmailer; 2008-04-01 at 11:12.

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

    Re: CTelephony (CActive) didn't invoke RunL()

    If i am not wrong you are missed to call CNetworkInfo::Process() ....

  3. #3
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122

    Re: CTelephony (CActive) didn't invoke RunL()

    Another issue: NewL() returns a dangling pointer - the newly created object is deleted by CleanupStack::PopAndDestroy().

    Lauri

  4. #4
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Ukraine
    Posts
    56

    Re: CTelephony (CActive) didn't invoke RunL()

    I just miss to post process
    also, when I cancel request DoCancel() works fine

    I mean when I delete iNetworkInfo in destuctor CEngine
    DoCancel works

    Any suggestions?

  5. #5
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Ukraine
    Posts
    56

    Re: CTelephony (CActive) didn't invoke RunL()

    Another issue: NewL() returns a dangling pointer - the newly created object is deleted by CleanupStack::PopAndDestroy().
    I thought NewLC put object to CleanupStack
    Please, explain me more detailed

    what you thing it should be fine

  6. #6
    Registered User
    Join Date
    Aug 2003
    Location
    Oulu, Finland
    Posts
    1,122

    Re: CTelephony (CActive) didn't invoke RunL()

    Quote Originally Posted by sashaslonmailer View Post
    I thought NewLC put object to CleanupStack
    Please, explain me more detailed

    what you thing it should be fine
    Yes, NewLC() pushes the object to cleanup stack. PopAndDestroy() removes it from there AND deletes the object. Therefore your NewL() is returning a pointer to a deleted object. You should use Pop() instead of PopAndDestroy().

    Lauri

  7. #7
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Ukraine
    Posts
    56

    Re: CTelephony (CActive) didn't invoke RunL()

    Oh.. such stupid mistake. Thank you very mach to point me

  8. #8
    Regular Contributor
    Join Date
    Nov 2007
    Location
    Ukraine
    Posts
    56

    Re: CTelephony (CActive) didn't invoke RunL()


Similar Threads

  1. Two CActive class in same project
    By morost in forum Symbian
    Replies: 4
    Last Post: 2007-10-03, 17:58
  2. How to use CActive Object for CTelephony
    By saadmansur in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2007-04-27, 11:31
  3. ActiveObject RunL is called just once
    By lskmao in forum Symbian
    Replies: 3
    Last Post: 2007-01-18, 15:15
  4. Replies: 2
    Last Post: 2006-08-30, 21:33
  5. Cancelling CActive and RunL
    By yaront in forum Symbian
    Replies: 3
    Last Post: 2005-01-12, 07:45

Posting Permissions

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