×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Always No recent call

    I'm using Carbide.c++ v2.3.0
    Symbian S60 3rd Ed FP1 SDK


    I tested this code and it always show me "No recent call." , why is that ?? although I have many incoming,missed and dialed numbers in my log !!!


    http://wiki.forum.nokia.com/index.ph...g_recent_calls


    I created the Active Object this way : -

    Code:
    
    /**
    
    * Handle the selected event.
    * @param aCommand the command id invoked
    * @return ETrue if the command was handled, EFalse if not
    */
    TBool CRecentMCContainerView::HandleGet_recentMenuItemSelectedL( TInt aCommand )
    
    {
    
    // TODO: implement selected event handler
    
    CLogHandler* iLogHandler = CLogHandler::NewLC();
    
    iLogHandler->ReadRecentEventsL();
    
    return ETrue;
    
    }

    by the way, after the Active object finishes , how to destroy it to cause no memory leak ??

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: Always No recent call

    may be you need to add CAPABILITY ReadUserData in the mmp file.

  3. #3
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: Always No recent call

    Many thanks vineet.jain for your help, I forgot to add the capabilities to the project .......

    But now after adding it , it gives me CBase 46 panic , which means Stray Signal Panic related to Active Scheduler .......

    I found this Topic here Talking about the same problem , And I followed there steps to check the code but everything seems to be OK .....


    Again I got the code from here http://wiki.forum.nokia.com/index.ph...g_recent_calls , And I didn't add any modification yet , just calling the AO as shown in the my first post !!!



    Any more help would be appreciated.

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: Always No recent call

    CActiveScheduler::Add(this);

    is this statement written in your code ?

    Also can you paste here you full code.

  5. #5
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: Always No recent call

    Yes , I added CActiveScheduler::Add(this); under ConstructL


    LogHandler.h
    Code:
    /*
     * LogHandler.h
     *
     *  Created on: Mar 7, 2011
     *      Author: Ashraf Fawzy
     */
    
    #ifndef LOGHANDLER_H_
    #define LOGHANDLER_H_
    
    #include <e32base.h>
    #include <logcli.h>   // CLogClient
    #include <logview.h>  // CLogViewRecent
     
    enum TTask
        {
        EGetRecent,
        ESleep
        };
     
    class CLogHandler : public CActive
        {
    public:
        /**
         * Symbian OS default constructor
         */
        CLogHandler();
     
        /**
         * 2nd phase constructor.
         */
        static CLogHandler* NewL();
     
        /**
         * 2nd phase constructor.
         */
        static CLogHandler* NewLC();
     
        /**
         * Destructor
         */
        ~CLogHandler();
     
        /**
         * Reads recent events from the main event database
         */
        void ReadRecentEventsL();
     
    private:
        /**
         * Symbian 2-phase constructor
         */
        void ConstructL();
     
        /**
         * From CActive
         */
        void RunL();
     
        /**
         * From CActive
         */
        TInt RunError(TInt anError);
     
        /**
         * From CActive
         */
        void DoCancel();
     
        /**
         * Handles a single recent event.
         */
        void HandleRecentEventL(const CLogEvent& anEvent);
     
    private: // Data
        RFs iFs;
     
        CLogClient* iLogClient;
        CLogViewRecent* iLogViewRecent;
     
        TTask iTask;    // Task for RunL
        };
     
    #endif /* LOGHANDLER_H_ */

    LogHandler.cpp
    Code:
    /*
     * LogHandler.cpp
     *
     *  Created on: Mar 7, 2011
     *      Author: Ashraf Fawzy
     */
    
    #include <aknnotewrappers.h>
    #include <e32base.h>
    #include <logcli.h>   // CLogClient
    #include <logview.h>  // CLogViewRecent
    #include <logwrap.h>  // CLogEvent
     
    #include "LogHandler.h"
     
    /**
     * Constructor. Defines the priority for this active object.
     */
    CLogHandler::CLogHandler() : CActive(EPriorityStandard)
        {
        }
     
    /**
     * 2nd phase constructor.
     */
    CLogHandler* CLogHandler::NewL()
        {
        CLogHandler* self = CLogHandler::NewLC();
        CleanupStack::Pop(self);
        return self;
        }
     
    /**
     * 2nd phase constructor.
     */
    CLogHandler* CLogHandler::NewLC()
        {
        CLogHandler* self = new (ELeave) CLogHandler();
        CleanupStack::PushL(self);
        self->ConstructL();
        return self;
        }
     
    /**
     * 2nd phase constructor.
     */
    void CLogHandler::ConstructL()
        {
        User::LeaveIfError(iFs.Connect());
     
        // Establish connection to log engine
        iLogClient = CLogClient::NewL(iFs);
        iLogViewRecent = CLogViewRecent::NewL(*iLogClient);
     
        iTask = ESleep; // Default task for RunL
     
        CActiveScheduler::Add(this);
        }
     
    /**
     * Destructor.
     */
    CLogHandler::~CLogHandler()
        {
        Cancel();
     
        delete iLogViewRecent;
        delete iLogClient;
     
        iFs.Close();
        }
     
    /**
     * From CActive.
     */
    void CLogHandler::RunL()
        {
        switch (iTask)
            {
            case EGetRecent:
                {
                // Retrieve the event and handle it
                HandleRecentEventL(iLogViewRecent->Event());
     
                // If there are more events in the log engine database...
                if (iLogViewRecent->NextL(iStatus))
                    {
                    if (iStatus == KErrNone)
                        {
                        // ... set active to get the next one
                        SetActive();
                        }
                    }
                else
                    {
                    // No more events. Go to sleep.
                    iTask = ESleep;
                    
                    }
                break;
                }
     
            case ESleep:
            default:
                {
                break;
                }
            }
        }
     
    /**
     * From CActive.
     */
    TInt CLogHandler::RunError(TInt anError)
        {
        return anError;
        }
     
    /**
     * From CActive.
     */
    void CLogHandler::DoCancel()
        {
        // Cancel the appropriate task
        switch (iTask)
            {
            case EGetRecent:
                {
                iLogViewRecent->Cancel();
                }
     
            case ESleep:
            default:
                {
                break;
                }
            }
        }
     
    /**
     * Reads recent events from the main event database
     */
    void CLogHandler::ReadRecentEventsL()
        {
        if (iLogViewRecent->SetRecentListL(KLogNullRecentList, iStatus))
            {
            if (iStatus == KErrNone)
                {
                // If there are events in the log view, set this active object active
                // to get the events from the main event database. See RunL().
                iTask = EGetRecent;
                SetActive();
                }
            }
        else
            {
            _LIT(KTxt, "No recent calls.");
            CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);
            note->ExecuteLD(KTxt);
            }
        }
     
    /**
     * Displays a recent event in an information note.
     */
    void CLogHandler::HandleRecentEventL(const CLogEvent& anEvent)
        {
        TBuf<255> buffer;
        _LIT(KTxt, "Description: %S\nNumber: %S");
        buffer.Format(KTxt, &(anEvent.Description()), &(anEvent.Number()));
        CAknInformationNote* note = new (ELeave)CAknInformationNote(ETrue);
        note->ExecuteLD(buffer);
        }

    My calling to AO from Pressing meun item:

    Code:
    /** 
     * Handle the selected event.
     * @param aCommand the command id invoked
     * @return ETrue if the command was handled, EFalse if not
     */
    TBool CRecentMCContainerView::HandleGet_recentMenuItemSelectedL( TInt aCommand )
    	{
    	// TODO: implement selected event handler
    	CLogHandler* iLogHandler = CLogHandler::NewLC();
    	iLogHandler->ReadRecentEventsL();
    	
    	return ETrue;
    	}
    I'm using carbide.c++ , Symbian GUI application project

  6. #6
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: Always No recent call

    inside : ReadRecentEventsL(), jsut in the beginning you may try calling Cancel() which would cancel all the pending requests if any.Also for this you need to implement DoCancel() in you class.

    void CLogHandler:: DoCancel()
    {
    if(iLogViewRecent )
    iLogViewRecent ->Cancel();

    if(iLogClient)
    iLogClient->Cancel();
    }


    void CLogHandler::ReadRecentEventsL()
    {
    Cancel();
    .
    .
    .
    }

  7. #7
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: Always No recent call

    Many thanks for your consistent help , but though I added Cacel(); to ReadRecentEventsL() , and changed my DoCancel() funtion to be as yours ..... I still get the same error !!!

    and again ... I got this code from this wiki here

  8. #8
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Always No recent call

    you could always try adding the CActiveScheduler::Add(this); as a first line in your constructL, and if it does not help, then you might want to check which line gets executed last.

    Also just to make sure, is this code executed in normal Application framework application, or not ? and if not, did you construct & start the active scheduler ?

  9. #9
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: Always No recent call

    Quote Originally Posted by symbianyucca View Post
    you could always try adding the CActiveScheduler::Add(this); as a first line in your constructL, and if it does not help, then you might want to check which line gets executed last.
    I tried your idea about adding CActiveSchedular::Add(this) in the first line in ConstructL , but I have the same error.


    how can I check which line gets executed last ??


    Also just to make sure, is this code executed in normal Application framework application, or not ? and if not, did you construct & start the active scheduler ?
    I used Carbide.c++ with "GUI Application with UI Designer" option , without any editing from my side on the code

    except creating the AO on the heap

    Code:
    CLogHandler* iLogHandler = CLogHandler::NewLC();

    and calling its Asynchronous function.

    Code:
    iLogHandler->ReadRecentEventsL();


    Do I need to establish and create ActiveSchedular manually or Carbide creates it automatically ??

    Edit:
    I searched Wiki and found an answer to my question here which says that GUI application contains ActiveSchedular by default.



    any more help would be appreciated.
    Last edited by ashraf fawzy; 2011-03-07 at 15:57. Reason: Additional information

  10. #10
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Always No recent call

    "GUI Application with UI Designer" will make application that has application framework, thus it will have active scheduler, which also is started by the framework, thus that should be ok.

    Then, as you have also added the Active object into the scheduler, there would be only two cases that I can think of that could go wrong:

    1. There is a mismatch between SetActive() call and starting a Active object reguest
    2. There are multiple request set on at same time with one active object.

    hmm, and now that I did read the code, I suspect it is the ReadRecentEventsL function. Basically the iStatus in there is always different than KErrNone, since it is actually pending, and the actual error code can be read when the RunL is called.. Thus do change that and try again.

  11. #11
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,089

    Re: Always No recent call

    you can mail me your code if you want. I'll PM you my email id, there you can send zipped project.

  12. #12
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: Always No recent call

    Quote Originally Posted by symbianyucca View Post
    hmm, and now that I did read the code, I suspect it is the ReadRecentEventsL function. Basically the iStatus in there is always different than KErrNone, since it is actually pending, and the actual error code can be read when the RunL is called.. Thus do change that and try again.
    And you were right .............. I removed the iStatus == KErrNone in the ReadRecentEventsL function and it gave me the first recent event and then showed me the same panic , so I removed iStatus == KErrNoe from RunL and it works great now.



    And now I need to know why the coder who wrote this code in the Wiki used iStatus == KErrNone ?? Was there any benefit of using it ?? And removing it may cause unhandled errors in further usage ??




    I hope to answer this important question based on the code above ,

    How to destroy this AO (CLogHandler) after it finishes shoing me recent events considering memory leak threat ??





    Againg Many thanks for you and for vineet.jain for this great help

  13. #13
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,751

    Re: Always No recent call

    There is no "benefit" in that, it is a programming error. If an asynchronous request is made, it always has a result.

    EDIT: for the other question on the comment page: it is a C-object, you simply delete it when you do not need it any more.

  14. #14
    Registered User
    Join Date
    May 2010
    Location
    Egypt
    Posts
    433

    Re: Always No recent call

    Many thanks for your answer wizard_hu_ , But I need to know in such code ( who has a loop to look for recent calls) where do I add "delete iLogHandler" ??

    Do I add it in the RunL function :

    Code:
    void CLogHandler::RunL()
        {
        switch (iTask)
            {
            case EGetRecent:
                {
                // Retrieve the event and handle it
                HandleRecentEventL(iLogViewRecent->Event());
                // If there are more events in the log engine database...
                if (iLogViewRecent->NextL(iStatus))
                    {
                        // ... set active to get the next one
                        SetActive();
                    }
                else
                    {
                    // No more events. Go to sleep.
                    iTask = ESleep;
                    
                    delete this;  //-------------------------------------------------------------------------> is this right ??
                    }
                break;
                }
     
            case ESleep:
            default:
                {
                break;
                }
            }
        }

    And changed my Active Object creation from NewLC to NewL to avoid Kern-Exec 3 error.


    Is this modifications are right or I'm missing something ??

  15. #15
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,169

    Re: Always No recent call

    Basically some class is propably holding a pointer to the class, thus it would be better to let that class to own this AO, and thus let it delete the pointer as well as set it NULL to avoid double deletions. If you self destruct, the class that has the pointer to this AO would really have no clue whether its non-NULL pointer is valid or not.

Similar Threads

  1. Delete call logs/ recent calls
    By NRK in forum Symbian
    Replies: 6
    Last Post: 2009-09-17, 09:16
  2. Recent call log not working on phone
    By yogi-am in forum Symbian
    Replies: 21
    Last Post: 2009-09-01, 15:13
  3. Delete Recent Received Call Log
    By pavan in forum Symbian
    Replies: 3
    Last Post: 2007-01-02, 12:47
  4. Recent Call , Inbox,Draft,Sent SMS
    By only_loooser in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2006-01-06, 22:51
  5. Nokia 30 recent call lists
    By colinc in forum Nokia M2M
    Replies: 0
    Last Post: 2004-03-08, 14:04

Posting Permissions

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