userlibandfileserver/fileserver/sfsrv/cl_notification.cpp
changeset 299 b5a01337d018
parent 0 a41df078684a
equal deleted inserted replaced
297:b2826f67641f 299:b5a01337d018
   177  * The order of the data in the buffer is:
   177  * The order of the data in the buffer is:
   178  * Word1   : NotificationSize (2 bytes) , PathSize (2 bytes)
   178  * Word1   : NotificationSize (2 bytes) , PathSize (2 bytes)
   179  * Word2   : NewNameSize (2 bytes) , NotificationType (2 bytes)
   179  * Word2   : NewNameSize (2 bytes) , NotificationType (2 bytes)
   180  * Word3   : UID
   180  * Word3   : UID
   181  * Word(s) : Path (TText8) , [Any sub-class members]
   181  * Word(s) : Path (TText8) , [Any sub-class members]
   182 
   182  */
   183 EXPORT_C TInt TFsNotification::DriveNumber(TInt& aDriveNumber) const
   183 EXPORT_C TInt TFsNotification::DriveNumber(TInt& aDriveNumber) const
   184 	{
   184 	{
   185 	TPtrC path(NULL,0);
   185 	TPtrC path(NULL,0);
   186 	TInt r = Path(path);
   186 	TInt r = Path(path);
   187 	if(r == KErrNone)
   187 	if(r == KErrNone)
   191 			r = RFs::CharToDrive(path[0],aDriveNumber);
   191 			r = RFs::CharToDrive(path[0],aDriveNumber);
   192 			}
   192 			}
   193 		}
   193 		}
   194 	return r;
   194 	return r;
   195 	}
   195 	}
   196 	*/
   196 	
   197 
   197 
   198 /*
   198 /*
   199  * The order of the data in the buffer is:
   199  * The order of the data in the buffer is:
   200  * Word1   : NotificationSize (2 bytes) , PathSize (2 bytes)
   200  * Word1   : NotificationSize (2 bytes) , PathSize (2 bytes)
   201  * Word2   : NewNameSize (2 bytes) , NotificationType (2 bytes)
   201  * Word2   : NewNameSize (2 bytes) , NotificationType (2 bytes)
   202  * Word3   : UID
   202  * Word3   : UID
   203  * Word(s) : Path (TText8) , [Any sub-class members]
   203  * Word(s) : Path (TText8) , [Any sub-class members]
   204 
   204  */
   205 EXPORT_C TInt TFsNotification::UID(TUid& aUID) const
   205 EXPORT_C TInt TFsNotification::UID(TUid& aUID) const
   206     {
   206     {
   207     TUint* word3 = PtrAdd((TUint*)this, sizeof(TUint)*2);
   207     TUint* word3 = PtrAdd((TUint*)this, sizeof(TUint)*2);
   208     aUID.iUid = *word3;
   208     aUID.iUid = *word3;
   209     return KErrNone; 
   209     return KErrNone; 
   210     }
   210     }
   211 	*/
   211 	
   212 
   212 
   213 
   213 
   214 CFsNotificationList* CFsNotificationList::NewL(TInt aBufferSize)
   214 CFsNotificationList* CFsNotificationList::NewL(TInt aBufferSize)
   215 	{
   215 	{
   216 	CFsNotificationList* self = new(ELeave) CFsNotificationList;
   216 	CFsNotificationList* self = new(ELeave) CFsNotificationList;
   319 CFsNotifyBody::~CFsNotifyBody()
   319 CFsNotifyBody::~CFsNotifyBody()
   320 	{
   320 	{
   321 	}
   321 	}
   322 
   322 
   323 EXPORT_C TInt CFsNotify::AddNotification(TUint aNotificationType, const TDesC& aPath, const TDesC& aFilename)
   323 EXPORT_C TInt CFsNotify::AddNotification(TUint aNotificationType, const TDesC& aPath, const TDesC& aFilename)
   324 	{
   324     {
   325 	if(aNotificationType == 0 || (aPath.Length() <= 0 && aFilename.Length() <= 0))
   325     TInt pathLength = aPath.Length();
   326 		return KErrArgument;
   326     if(aNotificationType == 0 || (pathLength <= 0 && aFilename.Length() <= 0))
   327 
   327         return KErrArgument;
   328 	return iBody->iFsNotify.AddNotification(aNotificationType, aPath, aFilename);
   328 
   329 	}
   329     //Validate path.
       
   330     //Paths must be fully formed. i.e. with a valid or wild drive letter.
       
   331     if(pathLength)
       
   332         {
       
   333         if(aPath[0] != '*' && aPath[0] != '?')
       
   334             {
       
   335             TInt drive = KErrNotFound;
       
   336             TInt r = RFs::CharToDrive(aPath[0],drive);
       
   337 
       
   338             if(r!=KErrNone)
       
   339                 return KErrPathNotFound;
       
   340             if(drive < EDriveA || drive > EDriveZ)
       
   341                 return KErrPathNotFound;
       
   342             if(pathLength < 2)
       
   343                 return KErrPathNotFound;
       
   344             else if(aPath[1] != ':')
       
   345                 return KErrPathNotFound;
       
   346             }
       
   347         }
       
   348 
       
   349 
       
   350     return iBody->iFsNotify.AddNotification(aNotificationType, aPath, aFilename);
       
   351     }
   330 
   352 
   331 //Removes notification request, does not close session
   353 //Removes notification request, does not close session
   332 EXPORT_C TInt CFsNotify::RemoveNotifications()
   354 EXPORT_C TInt CFsNotify::RemoveNotifications()
   333 	{
   355 	{
   334 	return iBody->iFsNotify.RemoveNotifications();
   356 	return iBody->iFsNotify.RemoveNotifications();
   448 	{
   470 	{
   449 	Panic(ENotificationPanic);
   471 	Panic(ENotificationPanic);
   450 	return KErrNotSupported;
   472 	return KErrNotSupported;
   451 	}
   473 	}
   452 
   474 
   453 /*
       
   454 EXPORT_C TInt TFsNotification::DriveNumber(TInt&) const
   475 EXPORT_C TInt TFsNotification::DriveNumber(TInt&) const
   455 	{
   476 	{
   456 	Panic(ENotificationPanic);
   477 	Panic(ENotificationPanic);
   457 	return KErrNotSupported;
   478 	return KErrNotSupported;
   458 	}
   479 	}
   459 	
   480 	
   460 EXPORT_C TInt TFsNotification::UID(TUid& aUID) const
   481 EXPORT_C TInt TFsNotification::UID(TUid&) const
   461     {
   482     {
   462  	Panic(ENotificationPanic);
   483  	Panic(ENotificationPanic);
   463 	return KErrNotSupported;
   484 	return KErrNotSupported;
   464     }
   485     }
   465 */
       
   466 
   486 
   467 EXPORT_C CFsNotify* CFsNotify::NewL(RFs& , TInt)
   487 EXPORT_C CFsNotify* CFsNotify::NewL(RFs& , TInt)
   468 	{
   488 	{
   469 	Panic(ENotificationPanic);
   489 	Panic(ENotificationPanic);
   470 	User::Leave(KErrNotSupported);
   490 	User::Leave(KErrNotSupported);