userlibandfileserver/fileserver/sfile/sf_request.cpp
changeset 300 1d28c8722707
parent 286 48e57fb1237e
equal deleted inserted replaced
293:0659d0e1a03c 300:1d28c8722707
   469 	if(iOperation->Arg(3) == aType) return 3;
   469 	if(iOperation->Arg(3) == aType) return 3;
   470 	
   470 	
   471 	return(-1);
   471 	return(-1);
   472 	}
   472 	}
   473 
   473 
       
   474 /*
       
   475  * Gets the UID of the client 
       
   476  */
       
   477 TUid CFsRequest::Uid()
       
   478     {
       
   479     return TUid::Null();
       
   480     }
       
   481 
       
   482 TUid CFsMessageRequest::Uid()
       
   483     {
       
   484     return iUID;
       
   485     }
       
   486 
   474 
   487 
   475 TBool CFsMessageRequest::IsNotifierSpecific() const
   488 TBool CFsMessageRequest::IsNotifierSpecific() const
   476 	{
   489 	{
   477 #ifndef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
   490 #ifndef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
   478 	return EFalse;
   491 	return EFalse;
   908 	SetFreeChanged(EFalse);
   921 	SetFreeChanged(EFalse);
   909 	EnablePostIntercept(ETrue);
   922 	EnablePostIntercept(ETrue);
   910 	}
   923 	}
   911 
   924 
   912 	
   925 	
   913 void CFsMessageRequest::Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession)
   926 void CFsMessageRequest::Set(const RMessage2& aMessage,const TOperation& aOperation,CSessionFs* aSession, TUid aUid)
   914 //
   927 //
   915 //
   928 //
   916 //
   929 //
   917 	{
   930 	{
       
   931     iUID = aUid;
   918 	iCurrentPlugin=NULL;
   932 	iCurrentPlugin=NULL;
   919 	iMessage=aMessage;
   933 	iMessage=aMessage;
   920 	iDrive=NULL;
   934 	iDrive=NULL;
   921 	iSubstedDrive=NULL;
   935 	iSubstedDrive=NULL;
   922 	CFsRequest::Set(aOperation,aSession);
   936 	CFsRequest::Set(aOperation,aSession);
   923 	SetFreeChanged(EFalse);
   937 	SetFreeChanged(EFalse);
   924 	EnablePostIntercept(ETrue);
   938 	EnablePostIntercept(ETrue);
   925 	}
       
   926 
       
   927 void CFsMessageRequest::Set(const TOperation& aOperation)
       
   928 	{
       
   929 	iOperation=const_cast<TOperation*>(&aOperation);
       
   930 	}
   939 	}
   931 
   940 
   932 void CFsMessageRequest::Process()
   941 void CFsMessageRequest::Process()
   933 //
   942 //
   934 // Process the request - (passing to a plugin or a drive thread)
   943 // Process the request - (passing to a plugin or a drive thread)
  1324 
  1333 
  1325 	TInt driveNumber = DriveNumber();
  1334 	TInt driveNumber = DriveNumber();
  1326 
  1335 
  1327 	if(aError==KErrNone)
  1336 	if(aError==KErrNone)
  1328 		{
  1337 		{
       
  1338 	    //Get a notificationInfo block (freed again after notification complete)
       
  1339 	    CFsNotificationInfo* notificationInfo = NULL; 
       
  1340 	    
  1329 		if(!(FsNotify::IsChangeQueEmpty(driveNumber)))
  1341 		if(!(FsNotify::IsChangeQueEmpty(driveNumber)))
  1330 			FsNotify::HandleChange(this,driveNumber);
  1342 		    {
  1331 	
  1343 		    if(CFsNotificationInfo::NotifyType(Operation()->Function()))
       
  1344 		        {
       
  1345 		        notificationInfo = CFsNotificationInfo::Allocate(*this); 
       
  1346 		        if(notificationInfo)
       
  1347 		            FsNotify::HandleChange(*notificationInfo);
       
  1348 		        }
       
  1349 		    }
       
  1350 
       
  1351 		
  1332 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
  1352 #ifdef SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
       
  1353 		
       
  1354 		if(!FsNotificationManager::IsInitialised())
       
  1355 		    {
       
  1356 	        if(notificationInfo)
       
  1357 	            {
       
  1358 	            CFsNotificationInfo::Free(notificationInfo);
       
  1359 	            }
       
  1360 		    return;
       
  1361 		    }
       
  1362 		
       
  1363         if(!notificationInfo)
       
  1364             {
       
  1365             TFsNotification::TFsNotificationType type;
       
  1366             CFsNotificationInfo::NotificationType(Operation()->Function(),type);
       
  1367             if(type)
       
  1368                 {
       
  1369                 notificationInfo = CFsNotificationInfo::Allocate(*this);
       
  1370                 if(!notificationInfo)
       
  1371                     return;
       
  1372                 }
       
  1373             else
       
  1374                 {
       
  1375                 return;
       
  1376                 }
       
  1377             }
  1333 		if 	(iOperation->iFunction == EFsFileWrite)
  1378 		if 	(iOperation->iFunction == EFsFileWrite)
  1334 			{
  1379 			{
  1335 			CFileShare* share = (CFileShare*) this->ScratchValue();
  1380 			CFileShare* share = (CFileShare*) this->ScratchValue();
  1336 			CFileCB* file = &share->File();
  1381 			CFileCB* file = &share->File();
  1337 			CFileCache* fileCache = file->FileCache();
  1382 			CFileCache* fileCache = file->FileCache();
  1338 			
  1383 			
  1339 			// Manage notifications for write with no cache or a write-through
  1384 			// Manage notifications for write with no cache or a write-through
  1340 			if (!fileCache || !fileCache->IsDirty())
  1385 			if (!fileCache || !fileCache->IsDirty())
  1341 				{
  1386 				{
  1342 				FsNotificationManager::HandleChange((CFsClientMessageRequest&)*this);
  1387 				FsNotificationManager::HandleChange(*notificationInfo);
  1343 				}
  1388 				}
  1344 			}
  1389 			}
  1345 		else if((iOperation->iFunction == EFsFileWriteDirty) && FsNotificationManager::IsInitialised())
       
  1346 			{
       
  1347 			CFileShare* share;
       
  1348 			CFileCB* file;
       
  1349 			GetFileFromScratch(this, share, file);
       
  1350 
       
  1351 			TFileName path;
       
  1352 			path.Append(file->DriveNumber() + 'A');
       
  1353 			path.Append(':');
       
  1354 			path.Append(file->FileName().Des());
       
  1355 			
       
  1356 			// Manage notifications for write with caching enabled
       
  1357 			FsNotificationManager::HandleChange((CFsClientMessageRequest*)this, path, TFsNotification::EFileChange);
       
  1358 			}
       
  1359 		else if(IsNotifierSupported())
  1390 		else if(IsNotifierSupported())
  1360 			{
  1391 			{
  1361 			FsNotificationManager::HandleChange((CFsClientMessageRequest&)*this);
  1392 			FsNotificationManager::HandleChange(*notificationInfo);
  1362 			}
  1393 			}
  1363 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
  1394 #endif //SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION
  1364 		}
  1395 		
       
  1396 		//Free the notificationInfo block
       
  1397 		if(notificationInfo)
       
  1398 		    CFsNotificationInfo::Free(notificationInfo);
       
  1399 		}// Err==KErrNone
  1365 	}
  1400 	}
  1366 
  1401 
  1367 void CFsMessageRequest::DoNotifyDiskSpace(TInt aError)
  1402 void CFsMessageRequest::DoNotifyDiskSpace(TInt aError)
  1368     {
  1403     {
  1369     __PRINT1(_L("----- CFsMessageRequest::DoNotifyDiskSpace() with %d"),aError);
  1404     __PRINT1(_L("----- CFsMessageRequest::DoNotifyDiskSpace() with %d"),aError);
  1780 
  1815 
  1781 
  1816 
  1782 void CFsMessageRequest::SetOperationFunc(TInt aFunction)
  1817 void CFsMessageRequest::SetOperationFunc(TInt aFunction)
  1783 	{
  1818 	{
  1784 	const TOperation& oP = OperationArray[aFunction];
  1819 	const TOperation& oP = OperationArray[aFunction];
  1785 	Set(oP);
  1820 	iOperation = const_cast<TOperation*>(&oP);
  1786 	// modified because some requests were set to PostInitialise. They are set to DoRequest in Dispatch anyway, so this is possibly ok?
  1821 	// modified because some requests were set to PostInitialise. They are set to DoRequest in Dispatch anyway, so this is possibly ok?
  1787 	//__ASSERT_ALWAYS(iReqState == EReqStateDoRequest, Fault(EInvalidMsgState));
  1822 	//__ASSERT_ALWAYS(iReqState == EReqStateDoRequest, Fault(EInvalidMsgState));
  1788 	}
  1823 	}
  1789 
  1824 
  1790 TInt CFsMessageRequest::PushOperation(TFsRequestFunc aCallback, TInt aNextState, TInt aFunction)
  1825 TInt CFsMessageRequest::PushOperation(TFsRequestFunc aCallback, TInt aNextState, TInt aFunction)