browserutilities/feedsengine/FeedsServer/Server/src/FeedsServerSession.cpp
changeset 10 a359256acfc6
parent 5 10e98eab6f85
child 25 0ed94ceaa377
--- a/browserutilities/feedsengine/FeedsServer/Server/src/FeedsServerSession.cpp	Fri Jul 03 15:54:40 2009 +0100
+++ b/browserutilities/feedsengine/FeedsServer/Server/src/FeedsServerSession.cpp	Thu Aug 27 07:44:59 2009 +0300
@@ -416,7 +416,17 @@
     // Ensure the server is ready.
     iFeedsServer.WakeupServerL();
     iCurrOp = aMessage.Function();
-    
+
+    if ( (!IsSpaceAvailableL()) && ((iCurrOp != EFeedsServerGetRootFolder) ||
+                                (iCurrOp != EFeedsServerWatchFolderList) || (iCurrOp != EFeedsServerGetSettings) ||
+                                (iCurrOp != EFeedsServerWatchSettings) || (iCurrOp != EFeedsServerSetConnection) ||
+                                (iCurrOp != EFeedsServerDisconnectManualUpdateConnection) ||
+                                (iCurrOp != EFeedsServerCancelAll) || (iCurrOp != EFeedsServerGetFeed) ||
+                                (iCurrOp != EFeedsServerPrintDBTables)))
+        {
+        User::Leave(KErrNoMemory);
+        }
+
     switch (iCurrOp)
         {
 	    case EFeedsServerGetRootFolder:
@@ -681,10 +691,16 @@
             //Gyanendra TODO // should create entry into database
             if (!iFeedsServer.iFeedsDatabase->FeedIdFromUrlL(feedUrl, folderListId, feedId))
                 {
+
+                if (!IsSpaceAvailableL())
+                    {
+                    aMessage.Complete(KErrNoMemory);
+                    }
+
                 //Find feed id from folder id
                 iFeedsServer.iFeedsDatabase->SetIsFolderTableUpdateNeeded(ETrue);
                 TInt entryId = iFeedsServer.iFeedsDatabase->FolderItemAddL(folderListId, feedUrl, feedUrl, EFalse, KRootFolderId, KAutoUpdatingOff);
-                iFeedsServer.iFeedsDatabase->FeedIdFromEntryId(entryId, folderListId, feedId);
+                iFeedsServer.iFeedsDatabase->FeedIdFromEntryIdL(entryId, folderListId, feedId);
                 updateNeeded = ETrue;
                 }
             }
@@ -728,23 +744,8 @@
         // Otherwise create a task to update the feed.
         else
             {
-
-            TInt drive( EDriveC );
-            TBool isSpace( EFalse );
-            RFs                 rfs;
-
-            User::LeaveIfError(rfs.Connect());
-            CleanupClosePushL(rfs);
-
-            TRAP_IGNORE( isSpace = !SysUtil::DiskSpaceBelowCriticalLevelL(
-                                                        &rfs,
-                                                        KMinFreebytes,
-                                                        drive ));
-
-            CleanupStack::PopAndDestroy();  //rfs
-            
             // Abort the updation of feeds under low memory.
-            if(isSpace)
+            if ( IsSpaceAvailableL() )
                 {
 
                 // If need be clean up the previous task.
@@ -2105,3 +2106,27 @@
 	}
 	return EFalse;
 }
+
+// -----------------------------------------------------------------------------
+// CFeedsServerSession::IsSpaceAvailableL
+//
+// This function checks whether disk space has not gone below critical level
+// -----------------------------------------------------------------------------
+//
+TBool CFeedsServerSession::IsSpaceAvailableL()
+{
+    TInt drive( EDriveC );
+    RFs  rfs;
+    TBool isSpaceAvailable(EFalse);
+
+    User::LeaveIfError(rfs.Connect());
+    CleanupClosePushL(rfs);
+
+    TRAP_IGNORE( isSpaceAvailable = !SysUtil::DiskSpaceBelowCriticalLevelL(
+                                                        &rfs,
+                                                        KMinFreebytes,
+                                                        drive ));
+    CleanupStack::PopAndDestroy();  //rfs
+
+    return isSpaceAvailable;
+}