×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    13

    Question Timer problem in device

    I'm building a simple incremental unzipper class.
    It unzips the file in chunks and takes short pauses in between them, using the timer example found in http://wiki.forum.nokia.com/index.ph...implementation.

    The pause is held because the zip file to be extracted is pretty huge and I don't want to choke the phone entirely.

    For some odd reason when testing this on device the RunL() method is never called after calling the RTimer.After() method. I've implemented similar proggressbar & timer system for a simple audioplayer class I modified from wiki example, which is basically very same as this one. I just can't see why this wouldn't work also.

    In emulator everything works fine, the timer calls the IncrementUnzip() and the zip file gets unzipped, and proggressbar updates.

    But in device the RunL() isn't called even for the first time after UnzipL() has called the RTimer.After().

    Any ideas why this would not work in the device?

    Or am I already way off on doing this, and should I just implement CZipExtrator as ActiveObject and not use the RTimer at all?

    For clarity I've only included the parts that are went through before the error occurs.

    Code:
    CZipExtractor* CZipExtractor::NewL()
        {
        CZipExtractor* self = CZipExtractor::NewLC();
        CleanupStack::Pop(self);
        return self;
        }
     
    CZipExtractor* CZipExtractor::NewLC()
        {
        CZipExtractor* self = new (ELeave) CZipExtractor();
        CleanupStack::PushL(self);
        self->ConstructL();
        return self;
        }
    
    void CZipExtractor::ConstructL()
    	{
    	iTimer = CIntervalTimer::NewL(CActive::EPriorityStandard,*this);
    	}
    
    TInt CZipExtractor::UnzipL(const TDesC& aFileName, const TFileName& aOutputFolder, MZipExtractorCallback* aLogger)
    	{
    	shouldStop = EFalse; 
    	
    	iCallBack = aLogger;
    	
        User::LeaveIfError(iFsSession.Connect());
        //iFsSession.ShareProtected();
        
    	iZipFile = CZipFile::NewL(iFsSession, aFileName);
    	iMembers = iZipFile->GetMembersL();
    	iOutputFolder.Copy(aOutputFolder);
    	
    	//Dialog
    	
    	iProgressDialog = new ( ELeave ) CAknProgressDialog( reinterpret_cast <CEikDialog**> ( &iProgressDialog ), ETrue );
    	iProgressDialog->SetCallback(this);
    	iProgressDialog->PrepareLC( R_PLAYBACK_DIALOG );
    	iProgressDialog->SetTextL(KDialogPleaseWait);
    	
    	iProgressInfo = iProgressDialog->GetProgressInfoL();	
    	TInt size;
    	iZipFile->Size(size);
    	iProgressInfo->SetFinalValue(size);
    	iProgressDialog->RunLD();
    	
    	iCallBack->Log(_L("Setting timer")); //This is reached in device & emulator
    	iTimer->After(KUnzipFreshTimeOut);
    	
    	}
    
    
    void CZipExtractor::DialogDismissedL( TInt aButtonId )
    	{
    	shouldStop = ETrue;
    	}
    
    void CZipExtractor::TimerExpired(TAny* /*aTimer*/,TInt aError)
    {
    	iCallBack->Log(_L("TimerExpired")); //This is never reached in device?
    	if(IncrementUnzip()) //More to unzip
    		{
    		iTimer->After(KUnzipFreshTimeOut);
    		}
    	//Something else 
    }
    Code:
    class MZipExtractorCallback
    	{
    	public:
    		virtual void Log(const TDesC& aTxt) = 0;
    		virtual void ZipExtractedCallback(TInt aError) = 0;
    	};
    
    class CZipExtractor : public CBase, public MProgressDialogCallback, MTimerNotify
        {
    public:
        static CZipExtractor* NewL();
        static CZipExtractor* NewLC();
         ~CZipExtractor();
    public: // public functions
       TInt UnzipL(const TDesC& aFileName, const TFileName& aOutputFolder, MZipExtractorCallback* aLogger);
    public: // implements MTimerNotify
    	void TimerExpired(TAny* aTimer,TInt aError);
    private: // internal functions
        void ConstructL();
        CZipExtractor();
        TBool IncrementUnzip();
    private: //private variabled   
        CIntervalTimer*					iTimer;
        
        CAknProgressDialog* iProgressDialog;
        CEikProgressInfo* iProgressInfo;
        
        CZipFileMemberIterator* iMembers;
        CZipFile* iZipFile;
        RFs iFsSession;
        
        TFileName iOutputFolder;
        
        MZipExtractorCallback* iCallBack;
    };

  2. #2
    Registered User
    Join Date
    Apr 2008
    Posts
    13

    Re: Timer problem in device

    I managed to find the answer.

    I use CSendUi in my application. I'm missing the necessary capabilities as I'm developing the software. Apparently the CSendUi::NewL() method causes some problems with active screduler (or something) if the capabilities are missing.

    This was fixed by only creating the CSendUi when capabilities are available:
    Code:
    RProcess me;
    if (me.HasCapability(ECapabilityNetworkServices) ) 
      {
      iSendUi = CSendUi::NewL(); 
      }
    This fixed the problems I was having with RTimer not responding.
    Hopefully this help someone having this problem in the future.

Similar Threads

  1. Socket connecting problem of Samsung device
    By cha9651 in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2008-11-10, 07:49
  2. Problem with Nokia device..
    By hkhan_2004 in forum Mobile Java General
    Replies: 2
    Last Post: 2008-08-05, 14:36
  3. Socket connection problem on N93 device
    By spaniard in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-03-29, 22:00
  4. Timer Task Problem to find Bluetooth device
    By amitkalyani in forum Bluetooth Technology
    Replies: 2
    Last Post: 2007-03-25, 18:49
  5. On device debugging using NetBeans problem
    By mckswk in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2006-11-06, 15:40

Posting Permissions

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