activityfw/storage/server/src/afstorage.cpp
changeset 112 dbfb5e38438b
parent 107 b34d53f6acdf
child 116 305818acdca4
--- a/activityfw/storage/server/src/afstorage.cpp	Fri Aug 06 13:40:46 2010 +0300
+++ b/activityfw/storage/server/src/afstorage.cpp	Wed Aug 18 10:39:24 2010 +0300
@@ -19,6 +19,7 @@
 #include <hash.h>
 #include <s32mem.h>
 
+#include "afdatabasecleaner.h"
 #include "afqueries.h"
 #include "afentry.h"
 
@@ -49,6 +50,7 @@
  */
 CAfStorage::~CAfStorage()
 {
+    delete mDatabaseCleaner;
     mActDb.Close();
     delete mFileStore;
 }
@@ -83,7 +85,10 @@
     BaflUtils::FileExists(mFsSession, path) ? OpenDbL(path) : CreateDbL(path);
     CleanupStack::PopAndDestroy(&path);
 
+    mDatabaseCleaner = new (ELeave) CAfDatabaseCleaner(mActDb);
+
     DeleteNonPersistentActivitiesL();
+    RequestCleanup();
 }
 
 // -----------------------------------------------------------------------------
@@ -659,3 +664,27 @@
     CleanupStack::PopAndDestroy(md5);
     return buf;
 }
+
+// -----------------------------------------------------------------------------
+/**
+ * Cancel ongoing cleanup if one is in progress.
+ * @return ETrue if the database cleanup was in progress, EFalse otherwise
+ */
+TBool CAfStorage::InterruptCleanup()
+{    
+    if (mDatabaseCleaner->IsActive()) {
+        mDatabaseCleaner->Cancel();
+        return ETrue;
+    } else {
+        return EFalse;
+    }
+}
+
+// -----------------------------------------------------------------------------
+/**
+ * Start database cleanup
+ */
+void CAfStorage::RequestCleanup()
+{
+    mDatabaseCleaner->StartCleanup();
+}