ut_diskspace_epoc.cpp

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2009-2009 HIIT and Tero Hasu
00003 // Copyright (c) 2007-2009 Google Inc.
00004 // Copyright (c) 2006-2007 Jaiku Ltd.
00005 // Copyright (c) 2002-2006 Mika Raento and Renaud Petit
00006 //
00007 // This software is licensed at your choice under either 1 or 2 below.
00008 //
00009 // 1. MIT License
00010 //
00011 // Permission is hereby granted, free of charge, to any person obtaining a copy
00012 // of this software and associated documentation files (the "Software"), to deal
00013 // in the Software without restriction, including without limitation the rights
00014 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00015 // copies of the Software, and to permit persons to whom the Software is
00016 // furnished to do so, subject to the following conditions:
00017 //
00018 // The above copyright notice and this permission notice shall be included in
00019 // all copies or substantial portions of the Software.
00020 //
00021 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00022 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00023 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00024 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00025 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00026 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00027 // THE SOFTWARE.
00028 //
00029 // 2. Gnu General Public license 2.0
00030 //
00031 // This program is free software; you can redistribute it and/or
00032 // modify it under the terms of the GNU General Public License
00033 // as published by the Free Software Foundation; either version 2
00034 // of the License, or (at your option) any later version.
00035 //
00036 // This program is distributed in the hope that it will be useful,
00037 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00038 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00039 // GNU General Public License for more details.
00040 //
00041 // You should have received a copy of the GNU General Public License
00042 // along with this program; if not, write to the Free Software
00043 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00044 //
00045 
00046 #include "ut_diskspace_epoc.hpp"
00047 
00048 #include "er_errors.h"
00049 #include "symbian_auto_ptr.hpp"
00050 
00051 #if defined(__EPOC32__)
00052 
00053 CDiskSpaceNotifier* CDiskSpaceNotifier::NewL(RFs& fs, TInt aDrive, 
00054                MDiskSpace* aNotifier, TInt64 aThreshold)
00055 {
00056   e_auto_ptr<CDiskSpaceNotifier> ret(new (ELeave) CDiskSpaceNotifier(fs, aDrive, 
00057                    aNotifier, aThreshold));
00058   ret->ConstructL();
00059   return ret.release();
00060 }
00061 
00062 CDiskSpaceNotifier::CDiskSpaceNotifier(RFs& fs, TInt aDrive, 
00063                MDiskSpace* aNotifier, TInt64 aThreshold) : 
00064   CActive(EPriorityNormal), iNotifier(aNotifier), iFs(fs), iDrive(aDrive),
00065   iThreshold(aThreshold)
00066 {
00067   CActiveScheduler::Add(this);
00068 }
00069 
00070 void CDiskSpaceNotifier::ConstructL()
00071 {
00072   MakeRequest(); // activate at initialization already
00073 }
00074 
00075 void CDiskSpaceNotifier::MakeRequest()
00076 {
00077   //iStatus=KRequestPending;
00078   iFs.NotifyDiskSpace(iThreshold, iDrive, iStatus);
00079   SetActive();
00080 }
00081 
00082 CDiskSpaceNotifier::~CDiskSpaceNotifier()
00083 {
00084   Cancel();
00085 }
00086 
00087 void CDiskSpaceNotifier::RunL()
00088 {
00089   TInt err = iStatus.Int();
00090 
00091   assert((err != KErrArgument) && "threshold value outside its limits");
00092 
00093   /*  xxx When could we get this? Not documented.
00094   if (err == KErrCorrupt) {
00095     return;
00096   }
00097   */
00098 
00099   // Make new request before notification, do nothing after the callback.
00100   MakeRequest();
00101 
00102   /*
00103   if (err != KErrNone) {
00104     logg("Unexpected, got error %d in DiskSpaceNotifier!", err);
00105   }
00106   */
00107 
00108   // Leave it to the caller to decide what to do about any possible error.
00109   iNotifier->DiskSpaceNotify(iDrive, err);
00110 }
00111 
00112 void CDiskSpaceNotifier::DoCancel()
00113 {
00114   iFs.NotifyDiskSpaceCancel();
00115 }
00116 
00117 #endif /* defined(__EPOC32__) */

ContextLogger2—ContextLogger2 Logger Daemon Internals—Generated on Mon May 2 13:49:57 2011 by Doxygen 1.6.1