voicerecorder/RecViewSrc/CVRDiskSpaceWatcher.cpp
branchRCL_3
changeset 20 072a5fa0c63b
parent 19 2f5c9ee7098c
child 21 c6bafb5162d8
equal deleted inserted replaced
19:2f5c9ee7098c 20:072a5fa0c63b
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *       Observe the Disk Space
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CVRMdaRecorder.h"
       
    22 #include "CVRDiskSpaceWatcher.h" 
       
    23 #include "CVRMemo.h"
       
    24 
       
    25 
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 // ---------------------------------------------------------------------------
       
    29 // CVRDiskSpaceWatcher::CVRDiskSpaceWatcher
       
    30 // 
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 inline CVRDiskSpaceWatcher::CVRDiskSpaceWatcher
       
    34         (CVRMdaRecorder& aRecorder, RFs& aFs) :
       
    35     CActive(CActive::EPriorityIdle),
       
    36     iRecorder(aRecorder), iFs(aFs)
       
    37     {
       
    38     CActiveScheduler::Add(this);
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 //CVRDiskSpaceWatcher::NewL
       
    43 // 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CVRDiskSpaceWatcher* CVRDiskSpaceWatcher::NewL
       
    47         (CVRMdaRecorder& aRecorder, RFs& aFs)
       
    48     {
       
    49     CVRDiskSpaceWatcher* self = new(ELeave) CVRDiskSpaceWatcher(aRecorder, aFs);
       
    50     return self;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CVRDiskSpaceWatcher::~CVRDiskSpaceWatcher
       
    55 // 
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CVRDiskSpaceWatcher::~CVRDiskSpaceWatcher()
       
    59     {
       
    60     Cancel();
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CVRDiskSpaceWatcher::DoCancel
       
    65 // 
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CVRDiskSpaceWatcher::DoCancel()
       
    69     {
       
    70     iFs.NotifyDiskSpaceCancel();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CVRDiskSpaceWatcher::RunL()
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 void CVRDiskSpaceWatcher::RunL()
       
    79     {
       
    80     // if error returns, restart AO
       
    81     if (iStatus.Int())
       
    82     	{
       
    83    	    if (iRecorder.iMemo->Quality() == EQualityHigh)
       
    84    	    	{
       
    85     	    RequestNotification( iThreshold, iDrive);	
       
    86    	    	}
       
    87     	return;	
       
    88     	}
       
    89 
       
    90     // Disk space is below CL -> initiate a compress
       
    91     if(iRecorder.iAudioRecorder->State() == CMdaAudioClipUtility::ERecording)
       
    92     	{
       
    93         iRecorder.StopAndNotify();	
       
    94     	}
       
    95  
       
    96     // Renew notification request
       
    97     if (iRecorder.iMemo)
       
    98     	{
       
    99     	if (iRecorder.iMemo->Quality() == EQualityHigh)
       
   100     		{
       
   101    	    	RequestNotification( iThreshold, iDrive);	
       
   102     		}    		
       
   103     	}
       
   104 
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CVRDiskSpaceWatcher::RunError
       
   109 // 
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 TInt CVRDiskSpaceWatcher::RunError(TInt /*aError*/)
       
   113     {
       
   114     return KErrNone;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CVRDiskSpaceWatcher::RequestNotification
       
   119 // 
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CVRDiskSpaceWatcher::RequestNotification( TInt64 aThreshold, TInt aDrive)
       
   123     {
       
   124     iThreshold = aThreshold;
       
   125     iDrive = aDrive;
       
   126     Cancel();
       
   127     iFs.NotifyDiskSpace(iThreshold,iDrive,iStatus);
       
   128     SetActive();
       
   129     }
       
   130 
       
   131 
       
   132 //  End of File