remotestoragefw/gsplugin/src/rsfwgsplugindrivelistcontainer.cpp
branchRCL_3
changeset 16 1aa8c82cb4cb
equal deleted inserted replaced
15:88ee4cf65e19 16:1aa8c82cb4cb
       
     1 /*
       
     2 * Copyright (c) 2003 - 2005 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:  The control container (view) of the remote drives list view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <aknappui.h> 
       
    21 #include    <eikspane.h>
       
    22 #include    <StringLoader.h>
       
    23 #include    <aknlists.h>
       
    24 #include 	<AknIconArray.h> 
       
    25 #include	<eikclbd.h>
       
    26 #include    <rsfwgspluginrsc.rsg>
       
    27 #include 	<avkon.mbg>
       
    28 #include	<AknQueryDialog.h>
       
    29 #include 	<rsfwgsplugin.mbg>
       
    30 #include    <aknnotewrappers.h>
       
    31 
       
    32 #include   	"rsfwgslocalviewids.h"
       
    33 #include    "rsfwgsplugindrivelistcontainer.h"
       
    34 #include    "rsfwgsplugin.h"
       
    35 #include	"rsfwmountman.h"
       
    36 #include    "rsfwcontrol.h"
       
    37 #include	"rsfwmountentry.h"
       
    38 
       
    39  _LIT(KTabulator, "\t");
       
    40  _LIT(KConnectedIcon, "\t0");
       
    41 
       
    42 // ============================ MEMBER FUNCTIONS ===============================
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CRsfwGsPluginDriveListContainer::CRsfwGsPluginDriveListContainer()
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CRsfwGsPluginDriveListContainer::CRsfwGsPluginDriveListContainer(CRsfwGsPlugin* aView) : iView(aView)
       
    49     {
       
    50     
       
    51     }
       
    52     
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // GSSettListRemoteDrivesListContainer::ConstructL
       
    56 // Symbian 2nd phase constructor can leave.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CRsfwGsPluginDriveListContainer::ConstructL(
       
    60     const TRect& aRect,
       
    61    	CRsfwMountMan* aMountMan)
       
    62     {
       
    63 	iMountMan = aMountMan;
       
    64 
       
    65     CEikStatusPane* sp = static_cast<CAknAppUi*> 
       
    66         ( iEikonEnv->EikAppUi() )->StatusPane();
       
    67     iTitlePane = static_cast<CAknTitlePane*> 
       
    68         ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
    69 
       
    70     // Set title
       
    71     StringLoader::Load ( iTitle, R_STR_REMOTE_DRIVES_VIEW_TITLE );
       
    72     iTitlePane->SetTextL(iTitle);// FromResourceL( rReader );
       
    73     CreateWindowL(); // Makes the control a window-owning control
       
    74 
       
    75     // Main List creation and initialization
       
    76     iMainList = new(ELeave) CAknSingleStyleListBox();
       
    77     iMainList->SetContainerWindowL(*this);
       
    78     iMainList->ConstructL(this, EAknListBoxLoopScrolling);
       
    79 
       
    80     // Main list scroll bar issues
       
    81     iMainList->CreateScrollBarFrameL(EFalse);
       
    82     iMainList->ScrollBarFrame()->SetScrollBarVisibilityL(
       
    83     CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
    84 
       
    85 	 // Empty text processing
       
    86 	 _LIT (KStringHeader, "%S\n%S");
       
    87     HBufC* emptyText = iEikonEnv->AllocReadResourceLC(R_GS_RSFW_NO_REMOTE_DRIVES);  
       
    88     HBufC* emptyText2 = iEikonEnv->AllocReadResourceLC(R_GS_RSFW_NO_REMOTE_DRIVES_EXPLANATORY); 
       
    89   	HBufC* myString = HBufC::NewLC(emptyText->Length() + emptyText2->Length() + 5);
       
    90   	TPtr emptyStringPtr = myString->Des();
       
    91   	emptyStringPtr.Format(KStringHeader, emptyText, emptyText2);
       
    92     
       
    93     iMainList->SetListBoxObserver(this);
       
    94     iMainList->View()->SetListEmptyTextL(*myString);
       
    95     CleanupStack::PopAndDestroy( 3 ); //emptyText, emptyText2, myString
       
    96 	
       
    97 	CArrayPtrFlat<CGulIcon>* iconArray = new(ELeave) CAknIconArray(4);
       
    98 	
       
    99 	CGulIcon* icon2;
       
   100 	icon2 = AknsUtils::CreateGulIconL(
       
   101         AknsUtils::SkinInstance(), 
       
   102         KAknsIIDQgnIndiConnectionOnAdd, 
       
   103         KGSPluginBitmapFile,
       
   104         EMbmRsfwgspluginQgn_indi_connection_on_add,
       
   105         EMbmRsfwgspluginQgn_indi_connection_on_add_mask);
       
   106 
       
   107 	CleanupStack::PushL(icon2);
       
   108 	iconArray->AppendL(icon2);
       
   109 	CleanupStack::Pop(icon2);  
       
   110 	
       
   111 	CGulIcon* icon3;
       
   112 	icon3 = AknsUtils::CreateGulIconL(
       
   113         AknsUtils::SkinInstance(), 
       
   114         KAknsIIDQgnIndiMarkedAdd, 
       
   115         AknIconUtils::AvkonIconFileName(),
       
   116         EMbmAvkonQgn_indi_marked_add,
       
   117         EMbmAvkonQgn_indi_marked_add_mask);
       
   118 
       
   119 	CleanupStack::PushL(icon3);
       
   120 	iconArray->AppendL(icon3);
       
   121 	CleanupStack::Pop(icon3);  
       
   122 	
       
   123 	(static_cast<CAknSingleStyleListBox *>(iMainList))->
       
   124 	    ItemDrawer()->ColumnData()->SetIconArray(iconArray);
       
   125  
       
   126     SetupListL();
       
   127     
       
   128     // Start receiving P&S notifier about the changes in drive connection states
       
   129     // if the key is not found, will leave with an error code
       
   130     // just ignore for now...
       
   131     TRAP_IGNORE(iDriveConnectObserver = CRsfwGsPropertyWatch::NewL(this));
       
   132         
       
   133     SetRect( aRect );
       
   134     ActivateL();
       
   135     
       
   136     iCoeEnv->AddForegroundObserverL( *this );
       
   137     }
       
   138     
       
   139 // ---------------------------------------------------------------------------
       
   140 // CRsfwGsPluginDriveListContainer::~CRsfwGsPluginDriveListContainer()
       
   141 // Destructor
       
   142 //  
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 CRsfwGsPluginDriveListContainer::~CRsfwGsPluginDriveListContainer()
       
   146     {
       
   147     if (iMainList)
       
   148         {
       
   149          delete iMainList;
       
   150         }
       
   151    
       
   152    if (iDriveConnectObserver)
       
   153         {
       
   154          delete iDriveConnectObserver;
       
   155         }   
       
   156     iCoeEnv->RemoveForegroundObserver( *this );     
       
   157     }
       
   158     
       
   159 // ---------------------------------------------------------------------------
       
   160 // CRsfwGsPluginDriveListContainer::SizeChanged()
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CRsfwGsPluginDriveListContainer::SizeChanged()
       
   164     {
       
   165     iMainList->SetRect(Rect());
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------------------
       
   169 // CRsfwGsPluginDriveListContainer::CountComponentControls() const
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 TInt CRsfwGsPluginDriveListContainer::CountComponentControls() const
       
   173     {
       
   174     return 1;
       
   175     }
       
   176     
       
   177 // ---------------------------------------------------------------------------
       
   178 // CRsfwGsPluginDriveListContainer::ComponentControl() const
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 CCoeControl* CRsfwGsPluginDriveListContainer::ComponentControl( TInt aIndex ) const
       
   182     {
       
   183     switch ( aIndex )
       
   184         {
       
   185         case 0:
       
   186             return iMainList;
       
   187         default:
       
   188             return NULL;
       
   189         }
       
   190     }
       
   191     
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // CRsfwGsPluginDriveListContainer::EditCurrentItemL()
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 void CRsfwGsPluginDriveListContainer::EditCurrentItemL()
       
   198     { 
       
   199     HBufC* currentDriveName = GetCurrentRemoteDriveNameLC();
       
   200     if (!(iView->IsDriveConnectedL())) 
       
   201         {       
       
   202         TPtrC drivePtr = currentDriveName->Ptr();
       
   203         iCurrentItemIndex=iMainList->CurrentItemIndex();
       
   204         TPtrC namePtr = drivePtr.Left(currentDriveName->Length());
       
   205         iView->LoadSettingsViewL(EEditExisting, namePtr, ETrue); 
       
   206           
       
   207         }
       
   208     else 
       
   209         {
       
   210         HBufC* myDisplayMessage = NULL;
       
   211         if ( currentDriveName->Length() )
       
   212             {
       
   213             myDisplayMessage = StringLoader::LoadLC( R_STR_RSFW_ERROR_EDIT_CONNECTED, *currentDriveName );
       
   214             }
       
   215         else
       
   216             {
       
   217             myDisplayMessage = StringLoader::LoadLC( R_STR_RSFW_ERROR_EDIT_CONNECTED );
       
   218             }
       
   219         CAknErrorNote* errorNote = new CAknErrorNote(EFalse);
       
   220         errorNote->ExecuteLD(*myDisplayMessage);
       
   221         CleanupStack::PopAndDestroy(myDisplayMessage);
       
   222         }
       
   223     CleanupStack::PopAndDestroy(currentDriveName);    
       
   224     }
       
   225     
       
   226 
       
   227 
       
   228 // ---------------------------------------------------------------------------
       
   229 // CRsfwGsPluginDriveListContainer::GetCurrentRemoteDriveNameLC()
       
   230 // ---------------------------------------------------------------------------
       
   231 //
       
   232 HBufC* CRsfwGsPluginDriveListContainer::GetCurrentRemoteDriveNameLC()
       
   233     {
       
   234     TPtrC16 remoteDriveName, remoteDriveNameClipped, remoteDriveNamePtr;
       
   235     TInt currentItemIndex = iMainList->CurrentItemIndex();
       
   236     if (currentItemIndex == KErrNotFound)
       
   237 	    {
       
   238 	    User::Leave(KErrNotFound);
       
   239 	    }
       
   240     remoteDriveName.Set(iRemoteDriveListArray->MdcaPoint(currentItemIndex));
       
   241     // remove '\t' from the beginning 
       
   242     remoteDriveNameClipped.Set(remoteDriveName.Mid(1)); 
       
   243    	// remove the trailing '\tn'if exists
       
   244     TInt posit = remoteDriveNameClipped.Find(KTabulator);
       
   245     if (posit != KErrNotFound) 
       
   246         {
       
   247         remoteDriveNamePtr.Set(remoteDriveNameClipped.Left(posit));
       
   248         }
       
   249     else 
       
   250         {
       
   251         remoteDriveNamePtr.Set(remoteDriveNameClipped);
       
   252         }
       
   253 
       
   254     return remoteDriveNamePtr.AllocLC();    
       
   255     }
       
   256     
       
   257 // ---------------------------------------------------------------------------
       
   258 // CRsfwGsPluginDriveListContainer::GetRemoteDriveNameLC(TInt aIndex)
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 TPtrC CRsfwGsPluginDriveListContainer::GetRemoteDriveNameL(TInt aIndex)
       
   262     {
       
   263 	TPtrC16 remoteDriveName, remoteDriveNameClipped, remoteDriveNamePtr;
       
   264     remoteDriveName.Set(iRemoteDriveListArray->MdcaPoint(aIndex));
       
   265     // remove '\t' from the beginning 
       
   266     remoteDriveNameClipped.Set(remoteDriveName.Mid(1)); 
       
   267    	// remove the trailing '\tn'
       
   268     TInt posit = remoteDriveNameClipped.Find(KTabulator);
       
   269     if (posit != KErrNotFound) 
       
   270         {
       
   271         remoteDriveNamePtr.Set(remoteDriveNameClipped.Left(posit));
       
   272         }
       
   273     else 
       
   274         {
       
   275         remoteDriveNamePtr.Set(remoteDriveNameClipped);
       
   276         }
       
   277 
       
   278     return remoteDriveNamePtr;    
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // CRsfwGsPluginDriveListContainer::OfferKeyEventL()
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 TKeyResponse CRsfwGsPluginDriveListContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   286                                                             TEventCode aType )
       
   287     {
       
   288     if (iMainList)
       
   289         {
       
   290         // if cancel key is pressed and list is not empty, invoke deletion
       
   291         if ((aKeyEvent.iCode == EKeyBackspace ) && (aType == EEventKey) )
       
   292             {
       
   293             if(!IsListEmpty())
       
   294                 {
       
   295                 CRsfwGsPlugin* iTempView = static_cast<CRsfwGsPlugin*> (iView);
       
   296                 iTempView->DeleteRemoteDriveL();
       
   297                 }  
       
   298             return EKeyWasConsumed;
       
   299             }
       
   300         else 
       
   301             {
       
   302             TKeyResponse returnValue = iMainList->OfferKeyEventL (aKeyEvent, aType);
       
   303             if ((aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow ) 
       
   304                         && (aType == EEventKey))
       
   305                 {
       
   306                 // Cba needs to be updated any time the user goes through the drive list
       
   307                 // as MSK "Edit" is dependent on connection state
       
   308                 // Note that we had to call iMainList->OfferKeyEventL() first 
       
   309                 // to make sure that the correct drive is highlighted
       
   310                 iCurrentItemIndex = iMainList->CurrentItemIndex();
       
   311                 iView->UpdateCbaL();            
       
   312                 }
       
   313             return returnValue;
       
   314             }
       
   315         }
       
   316     return EKeyWasNotConsumed;    
       
   317     }
       
   318     
       
   319 // ---------------------------------------------------------------------------
       
   320 // CRsfwGsPluginDriveListContainer::HandleListBoxEventL()
       
   321 // ---------------------------------------------------------------------------
       
   322 //
       
   323 void CRsfwGsPluginDriveListContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
       
   324     {
       
   325     // if the Select Key has been pressed
       
   326     if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
       
   327     (aListBoxEvent == MEikListBoxObserver::EEventItemSingleClicked))
       
   328         {
       
   329         EditCurrentItemL();           
       
   330         }
       
   331     }
       
   332       
       
   333     
       
   334   
       
   335 // ---------------------------------------------------------------------------
       
   336 // CRsfwGsPluginDriveListContainer::SetupListL()
       
   337 // ---------------------------------------------------------------------------
       
   338 //
       
   339 void CRsfwGsPluginDriveListContainer::SetupListL()
       
   340     {
       
   341     CTextListBoxModel* model = iMainList->Model();
       
   342     model->SetOwnershipType(ELbmOwnsItemArray);
       
   343     
       
   344     iRemoteDriveListArray = static_cast<CDesCArray*>(model->ItemTextArray());
       
   345     LoadRemoteDriveListArrayL();
       
   346     }    
       
   347     
       
   348 
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CRsfwGsPluginDriveListContainer::LoadSettingsListArrayL()
       
   352 // ---------------------------------------------------------------------------
       
   353 //
       
   354 TInt CRsfwGsPluginDriveListContainer::LoadRemoteDriveListArrayL()
       
   355     {
       
   356     iTitlePane->SetTextL(iTitle);
       
   357     
       
   358     CDesCArray* remoteDriveList = NULL;
       
   359     remoteDriveList = GetRemoteDriveNamesL();
       
   360     CleanupStack::PushL(remoteDriveList);
       
   361     TInt remoteDriveListCount = remoteDriveList->Count();
       
   362     iRemoteDriveListArray->Reset();
       
   363     for (TInt i = 0; i< remoteDriveListCount; i++)
       
   364         {
       
   365         TBuf <KMaxFriendlyNameLength+5> string; // maximum name + \t + \tn
       
   366    		string.Append(KTabulator);
       
   367         string.Append(remoteDriveList->MdcaPoint(i));
       
   368         if ( IsDriveConnectedL(remoteDriveList->MdcaPoint(i))) 
       
   369        		{
       
   370        		string.Append(KConnectedIcon);
       
   371         	}
       
   372         iRemoteDriveListArray->AppendL(string);	
       
   373  
       
   374         }
       
   375     CleanupStack::PopAndDestroy(remoteDriveList); 
       
   376     iMainList->HandleItemRemovalL();
       
   377     iMainList->HandleItemAdditionL();
       
   378     return remoteDriveListCount;
       
   379     }
       
   380 
       
   381 
       
   382     
       
   383 // ---------------------------------------------------------------------------
       
   384 // CRsfwGsPluginDriveListContainer::IsListEmpty()
       
   385 // ---------------------------------------------------------------------------
       
   386 //
       
   387 TBool CRsfwGsPluginDriveListContainer::IsListEmpty()
       
   388     {
       
   389     if (iRemoteDriveListArray->Count())
       
   390         return EFalse;
       
   391     return ETrue;    
       
   392     }
       
   393     
       
   394 // ---------------------------------------------------------------------------
       
   395 // CRsfwGsPluginDriveListContainer::IsLastItem()
       
   396 // ---------------------------------------------------------------------------
       
   397 //
       
   398 TBool CRsfwGsPluginDriveListContainer::IsLastItem()
       
   399     {
       
   400     if (iRemoteDriveListArray->Count() == 1)
       
   401         return ETrue;
       
   402     return EFalse;    
       
   403     }    
       
   404     
       
   405     
       
   406 // ---------------------------------------------------------------------------
       
   407 // CRsfwGsPluginDriveListContainer::DeleteCurrentRemoteDriveL()
       
   408 // ---------------------------------------------------------------------------
       
   409 //
       
   410 void CRsfwGsPluginDriveListContainer::DeleteCurrentRemoteDriveL()
       
   411     {
       
   412     TBool deletingLast = EFalse;
       
   413     if (iMainList->CurrentItemIndex() == iMainList->BottomItemIndex()) 
       
   414         {
       
   415     	deletingLast = ETrue;
       
   416         }
       
   417     
       
   418     HBufC* currentDriveName = GetCurrentRemoteDriveNameLC();
       
   419     TPtrC drivePtr = currentDriveName->Ptr();
       
   420     iMountMan->DeleteMountEntryL(drivePtr.Left(currentDriveName->Length()));  
       
   421     iRemoteDriveListArray->Delete(iMainList->CurrentItemIndex());
       
   422     iMainList->HandleItemRemovalL();
       
   423     iMainList->DrawDeferred();
       
   424     CleanupStack::PopAndDestroy(currentDriveName);
       
   425     
       
   426     if (deletingLast) 
       
   427         {
       
   428     	if (iRemoteDriveListArray->Count() > 0) 
       
   429     		{
       
   430     		iMainList->SetCurrentItemIndex(iMainList->BottomItemIndex());	
       
   431     		}
       
   432     	
       
   433         }
       
   434     }    
       
   435 
       
   436 // ---------------------------------------------------------------------------
       
   437 // CRsfwGsPluginDriveListContainer::IsDriveConnectedL()
       
   438 // ---------------------------------------------------------------------------
       
   439 //    
       
   440 TBool CRsfwGsPluginDriveListContainer::IsDriveConnectedL(const TDesC& aName)
       
   441     {
       
   442     
       
   443     TInt err;
       
   444     const CRsfwMountEntry* mountEntry;
       
   445     TRsfwMountInfo mountInfo;
       
   446     TChar driveL;
       
   447     mountEntry = mountEntry = iMountMan->MountEntryL(aName);
       
   448     if (!mountEntry) 
       
   449         {
       
   450         User::Leave(KErrNotFound);
       
   451         }
       
   452     const HBufC* drive = (mountEntry->Item(EMountEntryItemDrive));
       
   453     if (drive && drive->Length())
       
   454         {
       
   455         driveL =(*drive)[0];
       
   456         } 
       
   457     else 
       
   458     	{
       
   459     	// getting drive letter failed
       
   460     	return EFalse;
       
   461     	}
       
   462     err = iMountMan->GetMountInfo(driveL, mountInfo);
       
   463     if ((err == KErrNone) && (mountInfo.iMountStatus.iConnectionState == KMountStronglyConnected)) 
       
   464     	{
       
   465     	return ETrue;
       
   466     	}
       
   467     return EFalse;  
       
   468     }
       
   469 
       
   470 // ---------------------------------------------------------------------------
       
   471 // CRsfwGsPluginDriveListContainer::SetDriveConnectedStateL()
       
   472 // ---------------------------------------------------------------------------
       
   473 // 
       
   474 void CRsfwGsPluginDriveListContainer::SetDriveConnectedStateL(const TDesC& aName, TBool aConnected)
       
   475 	{
       
   476 	TInt i;
       
   477 	for (i=0; i < iRemoteDriveListArray->Count(); i++) 
       
   478 		{
       
   479 		TPtrC driveString =  GetRemoteDriveNameL(i);
       
   480 		if (driveString.Compare(aName) == 0) 
       
   481 			{
       
   482 			// newString has space for the friendly name, tabulator and connected icon
       
   483 			TBuf<KMaxFriendlyNameLength+5> newString; 
       
   484 			newString.Append(KTabulator);
       
   485 		    newString.Append(driveString);	
       
   486    			if (aConnected) 
       
   487    				{
       
   488    				newString.Append(KConnectedIcon);
       
   489    				}
       
   490    			iRemoteDriveListArray->Delete(i);
       
   491     		iRemoteDriveListArray->InsertL(i, newString);	
       
   492     		iMainList->DrawDeferred();
       
   493     		// Cba needs to be updated as MSK "Edit" is dependent on connection state
       
   494     		iView->UpdateCbaL();		
       
   495 		break;
       
   496 			}
       
   497 	
       
   498 		}
       
   499 	
       
   500 	}
       
   501 
       
   502 // ---------------------------------------------------------------------------
       
   503 // CRsfwGsPluginDriveListContainer::ConnectCurrentRemoteDriveL()
       
   504 // ---------------------------------------------------------------------------
       
   505 //  
       
   506 void CRsfwGsPluginDriveListContainer::ConnectCurrentRemoteDriveL() 
       
   507 {  
       
   508 	User::LeaveIfError(iMountMan->SetMountConnectionStateBlind(GetCurrentRemoteDriveIdL(), 
       
   509 	                                    KMountStronglyConnected));
       
   510 }
       
   511 
       
   512 // ---------------------------------------------------------------------------
       
   513 // CRsfwGsPluginDriveListContainer::DisconnectCurrentRemoteDriveL()
       
   514 // ---------------------------------------------------------------------------
       
   515 //  
       
   516 void CRsfwGsPluginDriveListContainer::DisconnectCurrentRemoteDriveL() 
       
   517 {
       
   518 	User::LeaveIfError(iMountMan->SetMountConnectionState(GetCurrentRemoteDriveIdL(), 
       
   519 	                                    KMountNotConnected));
       
   520 
       
   521 }
       
   522 
       
   523 // ---------------------------------------------------------------------------
       
   524 // CRsfwGsPluginDriveListContainer::GetNextRemoteDriveNameL
       
   525 // ---------------------------------------------------------------------------
       
   526 //
       
   527 TDesC& CRsfwGsPluginDriveListContainer::GetNextRemoteDriveNameL()
       
   528     {
       
   529     // Always return "New drive" as the default starting name
       
   530     // in case there is already a drive with the name "new name"
       
   531     // user is not allowed to save the new drive before changing the name.
       
   532     StringLoader::Load(iSettingNewName, R_STR_REMOTE_DRIVE_NEW_NAME);
       
   533     return iSettingNewName; 
       
   534     }
       
   535     
       
   536     
       
   537     
       
   538 // ---------------------------------------------------------------------------
       
   539 // CRsfwGsPluginDriveListContainer::GetCurrentRemoteDriveIdL
       
   540 // ---------------------------------------------------------------------------
       
   541 //
       
   542 TChar CRsfwGsPluginDriveListContainer::GetCurrentRemoteDriveIdL()
       
   543     {
       
   544     const CRsfwMountEntry* mountEntry;
       
   545    	HBufC* currentDriveName = GetCurrentRemoteDriveNameLC();
       
   546    	TPtrC drivePtr = currentDriveName->Ptr();
       
   547  	mountEntry = iMountMan->MountEntryL(drivePtr.Left(currentDriveName->Length()));
       
   548  	if (!mountEntry) 
       
   549  	    {
       
   550  	    User::Leave(KErrNotFound);
       
   551  	    }
       
   552    	CleanupStack::PopAndDestroy(currentDriveName);
       
   553    	const HBufC* drive = (mountEntry->Item(EMountEntryItemDrive));
       
   554     if (drive && drive->Length())
       
   555         {
       
   556         return (*drive)[0];
       
   557         }
       
   558     
       
   559     // should not come here....
       
   560     // return the drive letter of the default drive
       
   561     RFs fs;
       
   562 	User::LeaveIfError(fs.Connect());
       
   563 	TChar defaultd;
       
   564 	fs.DriveToChar(EDriveC, defaultd);
       
   565 	fs.Close();
       
   566 	return defaultd;
       
   567     }    
       
   568     
       
   569 // ---------------------------------------------------------------------------
       
   570 // CRsfwGsPluginDriveListContainer::GetRemoteDriveNamesL
       
   571 // ---------------------------------------------------------------------------
       
   572 //
       
   573 CDesCArray* CRsfwGsPluginDriveListContainer::GetRemoteDriveNamesL()
       
   574     {
       
   575     CDesCArray* myArray = new (ELeave) CDesC16ArraySeg(4);
       
   576     iMountMan->GetMountNamesL(myArray);
       
   577     return myArray;
       
   578     }
       
   579           
       
   580 // ---------------------------------------------------------------------------
       
   581 // CRsfwGsPluginDriveListContainer::RemoteDriveCount
       
   582 // ---------------------------------------------------------------------------
       
   583 //
       
   584 TInt CRsfwGsPluginDriveListContainer::RemoteDriveCount()
       
   585     {
       
   586    	return iRemoteDriveListArray->Count();
       
   587     }
       
   588           
       
   589 // ---------------------------------------------------------------------------
       
   590 // CRsfwGsPluginDriveListContainer::HandleResourceChange()
       
   591 // ---------------------------------------------------------------------------
       
   592 //
       
   593 void CRsfwGsPluginDriveListContainer::HandleResourceChange( TInt aType )
       
   594     {
       
   595     if ( aType == KAknsMessageSkinChange ||
       
   596          aType == KEikDynamicLayoutVariantSwitch )
       
   597         {
       
   598         if (aType != KAknsMessageSkinChange) 
       
   599             {
       
   600             TRect mainPaneRect;
       
   601             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   602                                            mainPaneRect);
       
   603             SetRect( mainPaneRect );
       
   604             }
       
   605         DrawDeferred();
       
   606         CRsfwGsPlugin* iTempView = static_cast<CRsfwGsPlugin*> (iView);    
       
   607 
       
   608         iTempView->HandleResourceChangeManual(aType);      
       
   609         }
       
   610     CCoeControl::HandleResourceChange( aType );
       
   611     }
       
   612   
       
   613 // ---------------------------------------------------------------------------
       
   614 // CRsfwGsPluginDriveListContainer::HandleResourceChangeManual()
       
   615 // ---------------------------------------------------------------------------
       
   616 //
       
   617 void CRsfwGsPluginDriveListContainer::HandleResourceChangeManual(TInt aType)
       
   618     {
       
   619     if (aType != KAknsMessageSkinChange) 
       
   620         {
       
   621         TRect mainPaneRect;
       
   622         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   623                                        mainPaneRect);
       
   624         SetRect( mainPaneRect );
       
   625         }
       
   626     DrawDeferred();
       
   627     iMainList->HandleResourceChange(aType);
       
   628     }
       
   629 
       
   630 // ---------------------------------------------------------------------------
       
   631 // CRsfwGsPluginDriveListContainer::FocusChanged
       
   632 // Set focus on the selected listbox. For animated skins feature.
       
   633 // ---------------------------------------------------------------------------
       
   634 //
       
   635 void CRsfwGsPluginDriveListContainer::FocusChanged(TDrawNow /*aDrawNow*/)
       
   636     {
       
   637     if(iMainList)
       
   638         {
       
   639         iMainList->SetFocus( IsFocused() );
       
   640         }
       
   641     }
       
   642 
       
   643 // ---------------------------------------------------------------------------
       
   644 // CRsfwGsPluginDriveListContainer::GetHelpContext
       
   645 // This function is called when Help application is launched.
       
   646 // ---------------------------------------------------------------------------
       
   647 //
       
   648 void CRsfwGsPluginDriveListContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   649     {
       
   650     aContext.iMajor = KGSRsfwPluginUID;
       
   651     }    
       
   652 
       
   653 // ---------------------------------------------------------------------------
       
   654 // CRsfwGsPluginDriveListContainer::HandleGainingForeground
       
   655 // ---------------------------------------------------------------------------
       
   656 //    
       
   657 void CRsfwGsPluginDriveListContainer::HandleGainingForeground() 
       
   658     {
       
   659     TRAP_IGNORE(HandleGainingForegroundL());
       
   660     }
       
   661 
       
   662 // ---------------------------------------------------------------------------
       
   663 // CRsfwGsPluginDriveListContainer::HandleGainingForegroundL
       
   664 // Called from HandleGainingForeground in order to trap potential leaves.
       
   665 // ---------------------------------------------------------------------------
       
   666 //    
       
   667 void CRsfwGsPluginDriveListContainer::HandleGainingForegroundL() 
       
   668     {
       
   669     if (iView->CurrentContainer() == this) 
       
   670         {
       
   671         // update the drive list
       
   672         LoadRemoteDriveListArrayL();
       
   673         SetFocus();
       
   674         iView->ProcessDeletingDialog();
       
   675         iView->UpdateCbaL();
       
   676         }
       
   677     }
       
   678 
       
   679 // ---------------------------------------------------------------------------
       
   680 // CRsfwGsPluginDriveListContainer::HandleLosingForeground
       
   681 // ---------------------------------------------------------------------------
       
   682 //        
       
   683 void CRsfwGsPluginDriveListContainer::HandleLosingForeground() 
       
   684     {
       
   685     
       
   686     }   
       
   687     
       
   688 // ---------------------------------------------------------------------------
       
   689 // CRsfwGsPluginDriveListContainer::SetFocus
       
   690 // ---------------------------------------------------------------------------
       
   691 //
       
   692 void CRsfwGsPluginDriveListContainer::SetFocus()
       
   693     { 
       
   694     TInt remoteDriveCount = iRemoteDriveListArray->Count();
       
   695     
       
   696     if (remoteDriveCount > 0) 
       
   697         {
       
   698         if (iCurrentItemIndex >= remoteDriveCount) 
       
   699             {
       
   700             // set to the beginning of the list
       
   701             iCurrentItemIndex = 0;
       
   702             }
       
   703         
       
   704         iMainList->SetCurrentItemIndex(iCurrentItemIndex);
       
   705         }
       
   706     }
       
   707 
       
   708 // ---------------------------------------------------------------------------
       
   709 // CRsfwGsPluginDriveListContainer::SetFocusL
       
   710 // finds the given name on the drive list and sets focus accordingly
       
   711 // ---------------------------------------------------------------------------
       
   712 //
       
   713 void CRsfwGsPluginDriveListContainer::SetFocusL(const TDes& aDriveName)
       
   714     {
       
   715     CDesCArray* remoteDriveList = NULL;
       
   716     remoteDriveList = GetRemoteDriveNamesL();
       
   717     CleanupStack::PushL(remoteDriveList);
       
   718     
       
   719     for ( TInt i = 0; i < remoteDriveList->Count(); i++ )
       
   720         { 
       
   721         if (aDriveName.Compare(remoteDriveList->MdcaPoint(i)) == 0)
       
   722             {
       
   723             iMainList->SetCurrentItemIndex(i);
       
   724             CleanupStack::PopAndDestroy(remoteDriveList); 
       
   725             return;
       
   726             }
       
   727         }
       
   728     CleanupStack::PopAndDestroy(remoteDriveList);
       
   729         
       
   730     // if drive name not found on the list, use default behaviour
       
   731     SetFocus();
       
   732     }
       
   733     
       
   734         
       
   735 //  End of File