remotestoragefw/mountmanager/src/rsfwmountmanimpl.cpp
branchRCL_3
changeset 19 88ee4cf65e19
parent 16 87c71b25c937
child 20 1aa8c82cb4cb
equal deleted inserted replaced
16:87c71b25c937 19:88ee4cf65e19
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Mount manager
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <badesca.h> 
       
    21 #include <f32fsys.h> // KMaxVolumeNameLength
       
    22 #include <rsfwmountman.h>
       
    23 #include <rsfwmountentry.h>
       
    24 
       
    25 #include "rsfwinterface.h"
       
    26 #include "rsfwmountmanimpl.h"
       
    27 
       
    28 
       
    29 // CONSTANTS
       
    30 const TUint8 KDefaultDriveLetter = 'J';
       
    31  // system default if no other specified; 
       
    32  // remote drives should use letters from J: to Y:
       
    33  
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ==============================
       
    36 
       
    37 // ----------------------------------------------------------------------------
       
    38 // CRsfwMountManImpl::CRsfwMountManImpl
       
    39 // Constructor
       
    40 // ----------------------------------------------------------------------------
       
    41 //
       
    42 CRsfwMountManImpl::CRsfwMountManImpl()
       
    43     {
       
    44     }
       
    45 
       
    46 // ----------------------------------------------------------------------------
       
    47 // CRsfwMountManImpl::NewL
       
    48 // ----------------------------------------------------------------------------
       
    49 //
       
    50 CRsfwMountManImpl* CRsfwMountManImpl::NewL(TUint aDefaultFlags,
       
    51                                    MRsfwMountManObserver* aMountManObserver)
       
    52     {
       
    53     CRsfwMountManImpl* self = new (ELeave) CRsfwMountManImpl();
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL(aDefaultFlags, aMountManObserver);
       
    56     CleanupStack::Pop(self);
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // CRsfwMountManImpl::~CRsfwMountManImpl
       
    62 // ----------------------------------------------------------------------------
       
    63 //
       
    64 CRsfwMountManImpl::~CRsfwMountManImpl()
       
    65     {
       
    66     iFs.Close();
       
    67     if (iRsfwControlConnected)
       
    68         {
       
    69         iRsfwControl.Close();
       
    70         }
       
    71     delete iMountStore;
       
    72     
       
    73     iBlackList.Close();
       
    74     }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // CRsfwMountManImpl::GetMountNamesL
       
    78 // ----------------------------------------------------------------------------
       
    79 //
       
    80 void CRsfwMountManImpl::GetMountNamesL(CDesC16Array* aNames)
       
    81     {
       
    82     iMountStore->GetNamesL(aNames);
       
    83     }
       
    84 
       
    85 // ----------------------------------------------------------------------------
       
    86 // CRsfwMountManImpl::MountEntry
       
    87 // ----------------------------------------------------------------------------
       
    88 //
       
    89 const CRsfwMountEntry* CRsfwMountManImpl::MountEntryL(const TDesC& aName)
       
    90     {
       
    91     return iMountStore->LookupEntryByNameL(aName);
       
    92     }
       
    93 
       
    94 // ----------------------------------------------------------------------------
       
    95 // CRsfwMountManImpl::MountEntry
       
    96 // ----------------------------------------------------------------------------
       
    97 //
       
    98 const CRsfwMountEntry* CRsfwMountManImpl::MountEntryL(TChar aDriveLetter)
       
    99     {
       
   100     return iMountStore->LookupEntryByDriveL(aDriveLetter);
       
   101     }
       
   102 
       
   103 // ----------------------------------------------------------------------------
       
   104 // CRsfwMountManImpl::AddMountEntryL
       
   105 // ----------------------------------------------------------------------------
       
   106 //
       
   107 void CRsfwMountManImpl::AddMountEntryL(CRsfwMountEntry* aMountEntry)
       
   108     {
       
   109     // Take ownership
       
   110     CleanupStack::PushL(aMountEntry);
       
   111     
       
   112     // Look for existing configuration with the same friendly name
       
   113     // overwriting not allowed
       
   114     const HBufC* driveName = aMountEntry->Item(EMountEntryItemName);
       
   115     const CRsfwMountEntry* entry = MountEntryL(*driveName);
       
   116     if (entry)
       
   117         {
       
   118         User::Leave(KErrInUse);
       
   119         }
       
   120     // Also look for existing configuration with the same drive letter
       
   121     // overwriting not allowed
       
   122     TChar driveLetter = DriveLetterFromMountEntry(*aMountEntry);
       
   123     if (driveLetter != '?')
       
   124         {
       
   125         entry = MountEntryL(driveLetter);
       
   126         if (entry)
       
   127             {
       
   128             User::Leave(KErrInUse);
       
   129             }
       
   130         }
       
   131     else 
       
   132         {
       
   133         driveLetter = FreeDriveLetterL(driveLetter);
       
   134         TBuf<1> driveLetterBuf;
       
   135         driveLetterBuf.Append(driveLetter);
       
   136         // Replace '?' with the allocated drive letter
       
   137         aMountEntry->SetItemL(EMountEntryItemDrive, driveLetterBuf);
       
   138         }
       
   139    
       
   140     // find the number of remote drives in use
       
   141     // if 9 already new ones are not allowed
       
   142     TDriveList fsDriveList;   
       
   143     User::LeaveIfError(iFs.DriveList(fsDriveList, KDriveAttRemote));    
       
   144     TInt i;
       
   145     TInt remoteDrives = 0;
       
   146     for (i = EDriveA; i <= EDriveZ; i++)
       
   147         { 
       
   148         if (fsDriveList[i] & KDriveAttRemote)
       
   149             {
       
   150             remoteDrives++;
       
   151             }
       
   152         }
       
   153     
       
   154     if (remoteDrives == KMaxRemoteDrives)
       
   155         {
       
   156         User::Leave(KErrInUse);
       
   157         }
       
   158       
       
   159     // Save the friendly name (not guaranteed to survive CMountStore::AddEntryL
       
   160     HBufC* name = NULL;
       
   161     if (aMountEntry->Item(EMountEntryItemName))
       
   162         {
       
   163         name = aMountEntry->Item(EMountEntryItemName)->AllocL();
       
   164         }
       
   165 
       
   166     // Release ownership
       
   167     CleanupStack::Pop(aMountEntry);
       
   168     // Add mount configuration repository entry
       
   169     TRAPD(err, AddEntryL(aMountEntry));
       
   170     CleanupStack::PushL(name);
       
   171     User::LeaveIfError(err);
       
   172     
       
   173     // Add mount in File Server
       
   174     if (name)
       
   175         {
       
   176         User::LeaveIfError(MountFileSystem(*name, driveLetter));
       
   177         }
       
   178     else
       
   179         {
       
   180         _LIT(KRsfwNoName, "remotedrive");
       
   181         User::LeaveIfError(MountFileSystem(KRsfwNoName, driveLetter));
       
   182         }
       
   183         
       
   184     // finally set mountconnection state to disconnected
       
   185     // this will make in Remote File Engine what is called "disconnected dormant mount"    
       
   186     SetMountConnectionState(driveLetter, KMountNotConnected);
       
   187         
       
   188     CleanupStack::PopAndDestroy(name);
       
   189     }
       
   190 
       
   191 // ----------------------------------------------------------------------------
       
   192 // CRsfwMountManImpl::DeleteMountEntryL
       
   193 // ----------------------------------------------------------------------------
       
   194 //
       
   195 void CRsfwMountManImpl::DeleteMountEntryL(const TDesC& aName)
       
   196     {
       
   197     const CRsfwMountEntry* mountEntry = iMountStore->LookupEntryByNameL(aName);
       
   198     if (mountEntry)
       
   199         {
       
   200         TChar driveLetter = DriveLetterFromMountEntry(*mountEntry);
       
   201         if (driveLetter != '?')
       
   202             {
       
   203             DeleteMountEntryL(driveLetter);
       
   204             }
       
   205         }
       
   206     }
       
   207 
       
   208 // ----------------------------------------------------------------------------
       
   209 // CRsfwMountManImpl::DeleteMountEntryL
       
   210 // ----------------------------------------------------------------------------
       
   211 //
       
   212 void CRsfwMountManImpl::DeleteMountEntryL(TChar aDriveLetter)
       
   213     {
       
   214     const CRsfwMountEntry* mountEntry =
       
   215         iMountStore->LookupEntryByDriveL(aDriveLetter);
       
   216     if (mountEntry)
       
   217         {
       
   218         // Remove entry from configuration repository
       
   219         iMountStore->RemoveEntryL(aDriveLetter);
       
   220         // Dismount from file server and Remote File Engine
       
   221         ExecuteUnmount(aDriveLetter);
       
   222         }
       
   223     }
       
   224     
       
   225 // ----------------------------------------------------------------------------
       
   226 // CRsfwMountManImpl::EditMountEntryL
       
   227 // ----------------------------------------------------------------------------
       
   228 //
       
   229 void CRsfwMountManImpl::EditMountEntryL(CRsfwMountEntry* aMountEntry)
       
   230     {
       
   231     // take ownership
       
   232     CleanupStack::PushL(aMountEntry);
       
   233     
       
   234     // look for the drive based on the letter
       
   235     TChar driveLetter = DriveLetterFromMountEntry(*aMountEntry);
       
   236     const CRsfwMountEntry* entryByDrive = MountEntryL(driveLetter);
       
   237     if ( !entryByDrive )
       
   238         {
       
   239         User::Leave(KErrNotFound);
       
   240         }
       
   241 
       
   242     // check whether the name has changed
       
   243     TBool nameChanged = EFalse;
       
   244     const HBufC* newName = aMountEntry->Item(EMountEntryItemName);
       
   245     const HBufC* oldName = entryByDrive->Item(EMountEntryItemName);
       
   246     if ( newName->Compare(*oldName) != KErrNone )
       
   247         {
       
   248         nameChanged = ETrue;
       
   249         }
       
   250         
       
   251     // check whether URI has changed
       
   252     TBool uriChanged = EFalse;
       
   253     const HBufC* newUri = aMountEntry->Item(EMountEntryItemUri);
       
   254     const HBufC* oldUri = entryByDrive->Item(EMountEntryItemUri);
       
   255     if ( newUri->Compare(*oldUri) != KErrNone )
       
   256         {
       
   257         uriChanged = ETrue;
       
   258         }
       
   259 
       
   260     // if the name has changed -> check whether it is not used by the other mount entry
       
   261     if ( nameChanged )
       
   262         {
       
   263         const CRsfwMountEntry* entryByName = MountEntryL(*newName);
       
   264         if ( entryByName && entryByDrive != entryByName )
       
   265             {
       
   266             User::Leave(KErrInUse);
       
   267             }        
       
   268         }
       
   269    
       
   270     // release ownership and call MountStore API
       
   271     CleanupStack::Pop(aMountEntry);    
       
   272     AddEntryL(aMountEntry);
       
   273 
       
   274     // if URI has changed we have to unmount the drive from RFE in order 
       
   275     // to clear the cache and mount it again
       
   276     // note there is no need to make unmounting from File System
       
   277     if ( uriChanged )
       
   278         {
       
   279         TInt err;
       
   280         User::LeaveIfError(GetRsfwControlConnection());
       
   281         err = iRsfwControl.DismountByDriveLetter(driveLetter);
       
   282         if ((err != KErrNone) && (err != KErrNotFound)) 
       
   283             {
       
   284             User::Leave(err);
       
   285             }
       
   286         User::LeaveIfError(iRsfwControl.SetMountConnectionState(driveLetter, KMountNotConnected));
       
   287         }
       
   288 
       
   289     // if the name has changed -> change label in File System
       
   290     if ( nameChanged )
       
   291         {
       
   292         User::LeaveIfError(SetDriveNameToFileSystem(driveLetter, *newName));
       
   293         }
       
   294     }    
       
   295 
       
   296 // ----------------------------------------------------------------------------
       
   297 // CRsfwMountManImpl::MountL
       
   298 // ----------------------------------------------------------------------------
       
   299 //
       
   300 void CRsfwMountManImpl::MountL(TChar& aDriveLetter)
       
   301     {
       
   302     TInt driveNumber;
       
   303     User::LeaveIfError(iFs.CharToDrive(aDriveLetter, driveNumber));
       
   304     User::LeaveIfError(GetRsfwControlConnection());
       
   305     User::LeaveIfError(iRsfwControl.Mount(driveNumber));
       
   306     }
       
   307 
       
   308 // ----------------------------------------------------------------------------
       
   309 // CRsfwMountManImpl::MountL
       
   310 // ----------------------------------------------------------------------------
       
   311 //
       
   312 void CRsfwMountManImpl::MountBlindL(TChar& aDriveLetter)
       
   313     {
       
   314     TInt driveNumber;
       
   315     User::LeaveIfError(iFs.CharToDrive(aDriveLetter, driveNumber));
       
   316     User::LeaveIfError(GetRsfwControlConnection());
       
   317     User::LeaveIfError(iRsfwControl.MountBlind(driveNumber));
       
   318     }
       
   319 
       
   320 
       
   321 // ----------------------------------------------------------------------------
       
   322 // CRsfwMountManImpl::SetMountConnectionState
       
   323 // ----------------------------------------------------------------------------
       
   324 //
       
   325 TInt CRsfwMountManImpl::SetMountConnectionState(TChar aDriveLetter,
       
   326                                             TUint aConnectionState)
       
   327     {
       
   328     TInt err = GetRsfwControlConnection();
       
   329     if (err != KErrNone)
       
   330         {
       
   331         return err;
       
   332         }
       
   333 
       
   334     err = iRsfwControl.SetMountConnectionState(aDriveLetter, aConnectionState);
       
   335     return err;
       
   336     }
       
   337 
       
   338 // ----------------------------------------------------------------------------
       
   339 // CRsfwMountManImpl::IsAppOnBlackList
       
   340 // ----------------------------------------------------------------------------
       
   341 //
       
   342 TBool CRsfwMountManImpl::IsAppOnBlackList(TUid aUid)
       
   343     {
       
   344     TInt i;
       
   345     for ( i = 0; i < iBlackList.Count(); i++ )
       
   346         {
       
   347         if ( aUid == iBlackList[i] )
       
   348             {
       
   349             return ETrue;
       
   350             }
       
   351         }
       
   352     return EFalse;
       
   353     }
       
   354 
       
   355 // ----------------------------------------------------------------------------
       
   356 // CRsfwMountManImpl::GetAllDrivesL
       
   357 // ----------------------------------------------------------------------------
       
   358 //
       
   359 TInt CRsfwMountManImpl::GetAllDrivesL(TDriveList& aDriveList)
       
   360     {
       
   361     GetFsDriveListL(aDriveList, EFalse);
       
   362     return aDriveList.Length();
       
   363     }
       
   364 
       
   365 // ----------------------------------------------------------------------------
       
   366 // CRsfwMountManImpl::GetRemoteMountList
       
   367 // ----------------------------------------------------------------------------
       
   368 //
       
   369 TInt CRsfwMountManImpl::GetRemoteMountListL(TDriveList& aDriveList)
       
   370     {
       
   371     GetFsDriveListL(aDriveList, ETrue);
       
   372     return aDriveList.Length();
       
   373     }
       
   374 
       
   375 // ----------------------------------------------------------------------------
       
   376 // CRsfwMountManImpl::GetMountInfo
       
   377 // ----------------------------------------------------------------------------
       
   378 //
       
   379 TInt CRsfwMountManImpl::GetMountInfo(TChar aDriveLetter,
       
   380                                  TRsfwMountInfo& aMountInfo)
       
   381     {
       
   382     TInt err = GetRsfwControlConnection();
       
   383     if (err == KErrNone)
       
   384         {
       
   385         err = iRsfwControl.GetMountInfo(aDriveLetter, aMountInfo);
       
   386         }
       
   387     return err;
       
   388     }
       
   389 
       
   390 // ----------------------------------------------------------------------------
       
   391 // CRsfwMountManImpl::GetRsfwControlConnection
       
   392 // Set a Remote File Engine control connection unless
       
   393 // we already have a connection
       
   394 // ----------------------------------------------------------------------------
       
   395 //
       
   396 TInt CRsfwMountManImpl::GetRsfwControlConnection()
       
   397     {
       
   398     TInt err = KErrNone;
       
   399     if (!iRsfwControlConnected)
       
   400         {
       
   401         err = iRsfwControl.Connect();
       
   402         if (!err) 
       
   403             {
       
   404             iRsfwControlConnected = ETrue;   
       
   405             }
       
   406         }
       
   407     return err;
       
   408     }
       
   409 
       
   410 // ----------------------------------------------------------------------------
       
   411 // CRsfwMountManImpl::MountFileSystem
       
   412 // Install ERemoteFS file system plugin (if not already done) and
       
   413 // mount a filesystem designated with the given drive letter
       
   414 // on that file system
       
   415 // ----------------------------------------------------------------------------
       
   416 //
       
   417 TInt CRsfwMountManImpl::MountFileSystem(const TDesC& /*aDriveName*/,
       
   418                                     TChar aDriveLetter)
       
   419     {
       
   420     return SyncWithMounterExe(ETrue, aDriveLetter);
       
   421     }
       
   422         
       
   423 
       
   424 // ----------------------------------------------------------------------------
       
   425 // CRsfwMountManImpl::RemoteDriveCount
       
   426 // Get the number of remote mounts as seen by the File Server
       
   427 // ----------------------------------------------------------------------------
       
   428 //
       
   429 TInt CRsfwMountManImpl::RemoteMountCountL()
       
   430     {
       
   431     // Check if how many mounts there are (also dormant mounts are counted)
       
   432     TDriveList driveList;
       
   433     return GetRemoteMountListL(driveList);
       
   434     }
       
   435 
       
   436 // ----------------------------------------------------------------------------
       
   437 // CRsfwMountManImpl::DoUnmountL
       
   438 // Do conditional unmounting by consulting the user
       
   439 // ----------------------------------------------------------------------------
       
   440 //
       
   441 void CRsfwMountManImpl::DoUnmountL(TChar aDriveLetter, TUint /* aFlags */)
       
   442     {
       
   443     TInt err = ExecuteUnmount(aDriveLetter);
       
   444     User::LeaveIfError(err);
       
   445     }
       
   446 
       
   447 // ----------------------------------------------------------------------------
       
   448 // CRsfwMountManImpl::ExecuteUnmount
       
   449 // Do unconditional unmounting
       
   450 // ----------------------------------------------------------------------------
       
   451 //
       
   452 TInt CRsfwMountManImpl::ExecuteUnmount(TChar aDriveLetter)
       
   453     {
       
   454     TInt err = GetRsfwControlConnection();
       
   455     if (err != KErrNone)
       
   456         {
       
   457         return err;
       
   458         }
       
   459 
       
   460     // Drop the mount both from the File Server and from Remote File Engine
       
   461     TInt errFs = KErrNone;
       
   462     TInt driveNumber;
       
   463     err = iFs.CharToDrive(aDriveLetter, driveNumber);
       
   464     if (err != KErrNone)
       
   465         {
       
   466         return err;
       
   467         }
       
   468     TDriveInfo driveInfo;
       
   469     err = iFs.Drive(driveInfo, driveNumber);
       
   470     if (err != KErrNone)
       
   471         {
       
   472         return err;
       
   473         }    
       
   474     if (driveInfo.iDriveAtt & KDriveAttRemote)
       
   475         {
       
   476         // The mount is known by the File Server
       
   477         errFs = iFs.DismountFileSystem(KRemoteFSName, driveNumber);
       
   478         if (errFs == KErrPermissionDenied) 
       
   479     	    {
       
   480     		// Client does not have sufficient capabilities to do the operation
       
   481     		// execute mount with the boot mounter application
       
   482     		SyncWithMounterExe(ETrue, aDriveLetter);
       
   483     	    }
       
   484         }
       
   485     
       
   486     // We also request dismount from the RFE because
       
   487     // The File Server (eremotefs) does not pass the
       
   488     // dismount request to the RFE.
       
   489     err = iRsfwControl.DismountByDriveLetter(aDriveLetter);
       
   490     if (errFs != KErrNone)
       
   491         {
       
   492         // give priority to the File Server error
       
   493         err = errFs;
       
   494         }
       
   495     return err;
       
   496     }
       
   497 
       
   498 
       
   499 // ----------------------------------------------------------------------------
       
   500 // CRsfwMountManImpl::ConstructL
       
   501 // ----------------------------------------------------------------------------
       
   502 //
       
   503 void CRsfwMountManImpl::ConstructL(TUint aDefaultFlags,
       
   504                                    MRsfwMountManObserver* aMountManObserver)
       
   505     {
       
   506     iDefaultFlags = aDefaultFlags;
       
   507 
       
   508     User::LeaveIfError(iFs.Connect());
       
   509     iRsfwControlConnected = EFalse;
       
   510     iMountManObserver = aMountManObserver;
       
   511     iMountStore = CRsfwMountStore::NewL(this);
       
   512     LoadBlackListL();
       
   513     }
       
   514 
       
   515 // ----------------------------------------------------------------------------
       
   516 // CRsfwMountManImpl::FreeDriveLetterL
       
   517 // Find a drive letter that has not yet been allocated by the File Server or
       
   518 // defined in the mount configuration data base
       
   519 // If the suggested drive letter (given as an input parameter)
       
   520 // is already occupied, an adjacent letter in the alphabet is returned.
       
   521 // Letter '?' as an input parameter is equal to KDefaultDriveLetter.
       
   522 // Leave with KErrInUse if there are no free drive slots
       
   523 // ----------------------------------------------------------------------------
       
   524 //
       
   525 TChar CRsfwMountManImpl::FreeDriveLetterL(TChar aDriveLetter)
       
   526     {
       
   527     if (aDriveLetter == '?')
       
   528         {
       
   529         // Use the system default drive letter if none is specified
       
   530         aDriveLetter = KDefaultDriveLetter;
       
   531         }
       
   532     else if ((aDriveLetter < 'A') || (aDriveLetter > 'Z'))
       
   533         {
       
   534         aDriveLetter.UpperCase();
       
   535         }
       
   536 
       
   537     TInt driveNumber;
       
   538     User::LeaveIfError(iFs.CharToDrive(aDriveLetter, driveNumber));
       
   539 
       
   540     // Try to find a free drive around the given drive
       
   541 
       
   542     // Get drives that are already mounted in the File Server
       
   543     TDriveList fsDriveList;
       
   544     User::LeaveIfError(iFs.DriveList(fsDriveList, KDriveAttAll));  
       
   545     // scan first upwards, then downwards from the requested drive 
       
   546     // (or default drive letter) until a free and legal drive letter is found
       
   547     // remote drives should use letters from J: to Y:
       
   548     TInt i;
       
   549     for (i = driveNumber; i <= EDriveY; i++)
       
   550         { 
       
   551         if (fsDriveList[i] == 0)
       
   552             {
       
   553             User::LeaveIfError(iFs.DriveToChar(i, aDriveLetter));
       
   554             return aDriveLetter;
       
   555             }
       
   556         }
       
   557     for (i = driveNumber - 1; i >= EDriveJ; i--)
       
   558         { 
       
   559         if (fsDriveList[i] == 0)
       
   560             {
       
   561             User::LeaveIfError(iFs.DriveToChar(i, aDriveLetter));
       
   562             return aDriveLetter;
       
   563             }
       
   564         }
       
   565     
       
   566     //  no free drive letters for remote drives
       
   567     User::Leave(KErrInUse);
       
   568     return 0;
       
   569     }
       
   570 
       
   571 // ----------------------------------------------------------------------------
       
   572 // CRsfwMountManImpl::DriveLetterFromMountEntry
       
   573 // Build a TRsfwMountConfig
       
   574 // ----------------------------------------------------------------------------
       
   575 //
       
   576 TChar CRsfwMountManImpl::DriveLetterFromMountEntry(const CRsfwMountEntry& aMountEntry)
       
   577     {
       
   578     const HBufC* drive = aMountEntry.Item(EMountEntryItemDrive);
       
   579     if (drive && drive->Length())
       
   580         {
       
   581         return (*drive)[0];
       
   582         }
       
   583     else
       
   584         {
       
   585         return '?';
       
   586         }
       
   587     }
       
   588  
       
   589 // ----------------------------------------------------------------------------
       
   590 // CRsfwMountManImpl::AddEntryL
       
   591 // Add an entry in the mount configurarion store
       
   592 // ----------------------------------------------------------------------------
       
   593 //
       
   594 void CRsfwMountManImpl::AddEntryL(CRsfwMountEntry* aMountEntry)
       
   595     {
       
   596     iMountStore->AddEntryL(aMountEntry);
       
   597     }
       
   598  
       
   599 
       
   600 // ----------------------------------------------------------------------------
       
   601 // CRsfwMountManImpl::HandleMountStoreEvent
       
   602 // Handle a mount store change notification
       
   603 // ----------------------------------------------------------------------------
       
   604 //
       
   605 void CRsfwMountManImpl::HandleMountStoreEvent(TMountStoreEvent aEvent,
       
   606                                           TInt aStatus,
       
   607                                           TAny* aArg)
       
   608     {
       
   609     if (iMountManObserver)
       
   610         {
       
   611         if (aEvent == EMountStoreEventMountConfigurationChanged)
       
   612             {
       
   613             TRAP_IGNORE(iMountManObserver->HandleMountManEventL(
       
   614                 EMountManEventMountConfigurationChanged,
       
   615                 aStatus,
       
   616                 aArg));
       
   617             }
       
   618         }
       
   619     }
       
   620 
       
   621 // ----------------------------------------------------------------------------
       
   622 // CRsfwMountManImpl::SyncWithMounterExe
       
   623 // Uses boot mounter exe to mount or unmount remote drives in File Server
       
   624 // ----------------------------------------------------------------------------
       
   625 //
       
   626 TInt CRsfwMountManImpl::SyncWithMounterExe(TBool aSetDrive, TChar aDrive) 
       
   627 	{
       
   628 	TInt err;
       
   629 	RProcess mounter;
       
   630 	TRequestStatus status;
       
   631 	TBuf<5> parameter;
       
   632 	if (!aSetDrive) 
       
   633 	    {
       
   634 	    err = mounter.Create(KRsfwMounterExe, _L(""));
       
   635 	    }
       
   636     else 
       
   637         {
       
   638         parameter.Append(aDrive);
       
   639         err = mounter.Create(KRsfwMounterExe, parameter);
       
   640         }
       
   641 
       
   642     if (err == KErrNone) 
       
   643     	{
       
   644     	mounter.Resume();
       
   645     	mounter.Logon(status);
       
   646     	User::WaitForRequest(status);
       
   647     	mounter.Close();
       
   648     	err = status.Int();	
       
   649     	} 
       
   650     return err;
       
   651 	}
       
   652         
       
   653 // ----------------------------------------------------------------------------
       
   654 // CRsfwMountManImpl::GetFsDriveList
       
   655 //
       
   656 // Returns drive letters. Letters for remote drives in order defined in CenRep
       
   657 // ----------------------------------------------------------------------------
       
   658 //
       
   659 void CRsfwMountManImpl::GetFsDriveListL(TDriveList& aDriveList, TBool aRemoteOnly)
       
   660     {
       
   661     TDriveList driveList;
       
   662     // get local drives
       
   663     User::LeaveIfError(iFs.DriveList(driveList));
       
   664     
       
   665    // local drives are assumed to be from C:\ to R:\
       
   666     // these will go to the front of the list
       
   667     if (!aRemoteOnly) 
       
   668         {
       
   669         for (int i = EDriveC; i <= EDriveZ; i++) 
       
   670             {
       
   671             if ( (driveList[i]) && (!(driveList[i] & KDriveAttRemote)) )
       
   672                 {
       
   673                 TChar driveLetter;
       
   674                 User::LeaveIfError(iFs.DriveToChar(i, driveLetter));
       
   675                 aDriveList.Append(driveLetter);
       
   676                 }
       
   677             }
       
   678         }
       
   679       
       
   680     GetRemoteDriveListL(driveList);   
       
   681     
       
   682     for (int i = 0; i < driveList.Length(); i++) 
       
   683         {
       
   684         aDriveList.Append(driveList[i]);
       
   685         }
       
   686     }
       
   687 
       
   688 // ----------------------------------------------------------------------------
       
   689 // CRsfwMountManImpl::GetRemoteDriveList
       
   690 // ----------------------------------------------------------------------------
       
   691 //
       
   692 TInt CRsfwMountManImpl::GetRemoteDriveListL(TDriveList& aDriveList)
       
   693     {
       
   694     iMountStore->GetDriveLettersL(aDriveList); 
       
   695     return aDriveList.Length();
       
   696     }
       
   697 
       
   698 // ----------------------------------------------------------------------------
       
   699 // CRsfwMountManImpl::SetDriveNameToFileSystem
       
   700 // ----------------------------------------------------------------------------
       
   701 //
       
   702 TInt CRsfwMountManImpl::SetDriveNameToFileSystem(TChar aDriveLetter,
       
   703                                                  const TDesC& /*aDriveName*/)
       
   704     {
       
   705     return SyncWithMounterExe(ETrue, aDriveLetter); 
       
   706     }
       
   707     
       
   708 // ----------------------------------------------------------------------------
       
   709 // CRsfwMountManImpl::RefreshDirectoryL
       
   710 // ----------------------------------------------------------------------------
       
   711 //
       
   712 TInt CRsfwMountManImpl::RefreshDirectory(const TDesC& aPath)
       
   713     {
       
   714     TInt err;
       
   715     err = GetRsfwControlConnection();
       
   716     if (err != KErrNone) 
       
   717         {
       
   718         return err;
       
   719         }
       
   720     return iRsfwControl.RefreshDirectory(aPath); 
       
   721     }
       
   722     
       
   723 // ----------------------------------------------------------------------------
       
   724 // CRsfwMountManImpl::LoadBlackListL
       
   725 // ----------------------------------------------------------------------------
       
   726 //
       
   727 void CRsfwMountManImpl::LoadBlackListL()
       
   728     {
       
   729 
       
   730 //    const TUid app1 = TUid::Uid(0x00000000);
       
   731 //    const TUid app2 = TUid::Uid(0x00000001);
       
   732 //    const TUid app3 = TUid::Uid(0x00000002);
       
   733     
       
   734     iBlackList.Reset();
       
   735 //    iBlackList.AppendL(app1);
       
   736 //    iBlackList.AppendL(app2);
       
   737 //    iBlackList.AppendL(app3);
       
   738     }
       
   739 
       
   740 // ----------------------------------------------------------------------------
       
   741 // CRsfwMountManImpl::LoadBlackListL
       
   742 // ----------------------------------------------------------------------------
       
   743 //
       
   744 TInt CRsfwMountManImpl::CancelRemoteTransfer(const TDesC& aFile)
       
   745     {
       
   746     TInt err;
       
   747     err = GetRsfwControlConnection();
       
   748     if (err != KErrNone) 
       
   749         {
       
   750         return err;
       
   751         }
       
   752     return iRsfwControl.CancelRemoteTransfer(aFile);  
       
   753     }
       
   754     
       
   755 //  End of File