remotestoragefw/rsfwnotifierplugins/src/rsfwnotplugindlg.cpp
branchRCL_3
changeset 20 1aa8c82cb4cb
parent 0 3ad9d5175a89
equal deleted inserted replaced
19:88ee4cf65e19 20:1aa8c82cb4cb
       
     1 /*
       
     2 * Copyright (c) 2006 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:  RSFW notifier server plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AknNotifyStd.h>
       
    20 #include <eikenv.h>
       
    21 #include <AknQueryDialog.h>
       
    22 #include <AknGlobalNote.h>
       
    23 #include <ConeResLoader.h>
       
    24 #include <rsfwnotplugindlg.rsg>
       
    25 #include <StringLoader.h>
       
    26 #include <CAknMemorySelectionDialog.h>
       
    27 #include <CAknFileSelectionDialog.h>
       
    28 #include <sysutil.h>
       
    29 #include <bautils.h>
       
    30 #include <AknWaitDialog.h>
       
    31 #include <uikon/eiksrvui.h> // CEikServAppUi
       
    32 
       
    33 #include "rsfwnotplugindlg.h"
       
    34 #include "rsfwnotpluginnamedialog.h"
       
    35 #include "mdebug.h"
       
    36 
       
    37 #include <implementationproxy.h> 
       
    38 
       
    39 _LIT(KResourceFile, "z:\\resource\\RsfwNotPluginDlg.RSC"); // emulator
       
    40 
       
    41 
       
    42 void CreateNotifierL(CArrayPtr<MEikSrvNotifierBase2>* aNotifiers)
       
    43     {
       
    44     MEikSrvNotifierBase2* notifier;
       
    45     notifier = CRsfwNotPluginDlg::NewL();
       
    46     CleanupStack::PushL(notifier);
       
    47     aNotifiers->AppendL(notifier);
       
    48     CleanupStack::Pop(notifier);
       
    49     }
       
    50 
       
    51 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
       
    52     {
       
    53     CArrayPtrFlat<MEikSrvNotifierBase2>* notifiers
       
    54         = new CArrayPtrFlat<MEikSrvNotifierBase2>(1);
       
    55     if (notifiers)
       
    56         {
       
    57         TRAPD(err, CreateNotifierL(notifiers));
       
    58         if(err)
       
    59             {
       
    60             notifiers->ResetAndDestroy();
       
    61             delete notifiers;
       
    62             notifiers = NULL;
       
    63             }
       
    64         }
       
    65     return(notifiers);
       
    66     }
       
    67 
       
    68 
       
    69 
       
    70 CRsfwNotPluginDlg* CRsfwNotPluginDlg::NewL()
       
    71     {
       
    72     CRsfwNotPluginDlg* dlg = new(ELeave)CRsfwNotPluginDlg();
       
    73     CleanupStack::PushL(dlg);
       
    74     dlg->ConstructL();
       
    75     CleanupStack::Pop(dlg);
       
    76     return dlg;
       
    77     }
       
    78 
       
    79 CRsfwNotPluginDlg::~CRsfwNotPluginDlg()
       
    80     {
       
    81     Cleanup();
       
    82     iFs.Close(); 
       
    83     if (iWaitDialog) 
       
    84         {
       
    85         delete iWaitDialog;
       
    86         }
       
    87     // just in case make sure the app key is unblocked
       
    88     UnblockAppSwitching();
       
    89     }
       
    90     
       
    91 void CRsfwNotPluginDlg::Cleanup()
       
    92     {
       
    93     
       
    94     iMethod = TRsfwNotPluginRequest::ENoMethod;
       
    95     iCancelled = EFalse;  
       
    96     iReplySlot = NULL;  
       
    97  
       
    98     
       
    99     if (iUserName)
       
   100         {
       
   101         delete iUserName;
       
   102         iUserName = NULL;
       
   103         }
       
   104      
       
   105     if (iPassword)
       
   106         {
       
   107         delete iPassword;
       
   108         iPassword = NULL;
       
   109         }
       
   110     
       
   111     if (iCurrentRootPath)  
       
   112         {
       
   113         delete iCurrentRootPath;
       
   114         iCurrentRootPath = NULL;
       
   115         }
       
   116     
       
   117     
       
   118     if (iMemDialog) 
       
   119         {
       
   120         delete iMemDialog;
       
   121         iMemDialog = NULL;
       
   122         }
       
   123         
       
   124     if (iFileName) 
       
   125         {
       
   126         delete iFileName;
       
   127         iFileName = NULL;
       
   128         }
       
   129         
       
   130     if (iAuthRequest)
       
   131         {
       
   132         delete iAuthRequest;
       
   133         iAuthRequest = NULL;
       
   134         }
       
   135         
       
   136     if (iSaveToRequest) 
       
   137         {
       
   138         delete iSaveToRequest;
       
   139         iSaveToRequest = NULL;
       
   140         }
       
   141         
       
   142     if (iWaitDialog) 
       
   143         {
       
   144         delete iWaitDialog;
       
   145         iWaitDialog = NULL;
       
   146         }
       
   147        
       
   148     }
       
   149 
       
   150 CRsfwNotPluginDlg::CRsfwNotPluginDlg() : CActive(EPriorityStandard),
       
   151     iMethod(TRsfwNotPluginRequest::ENoMethod)
       
   152     {
       
   153     CActiveScheduler::Add(this);
       
   154     }
       
   155 
       
   156 void CRsfwNotPluginDlg::ConstructL()
       
   157     {
       
   158     User::LeaveIfError(iFs.Connect());
       
   159     iAppSwitchingBlocked = EFalse;
       
   160     }
       
   161 
       
   162 void CRsfwNotPluginDlg::RunL()
       
   163     {
       
   164     if(iMethod == TRsfwNotPluginRequest::ENoMethod)
       
   165         return; // Notifier canceled or request signaled by other means
       
   166 
       
   167     HandleAsyncRequestL(); // show dialog
       
   168     }
       
   169 
       
   170 TInt CRsfwNotPluginDlg::RunError(TInt aError)
       
   171     {
       
   172     DEBUGSTRING16(("CRsfwNotPluginDlg::RunError, error=%d",aError));
       
   173     UnblockAppSwitching();
       
   174     iMessage.Complete(aError);
       
   175     Cleanup();
       
   176     return KErrNone;
       
   177     }
       
   178 
       
   179 void CRsfwNotPluginDlg::DoCancel()
       
   180     {
       
   181     }
       
   182 
       
   183 /**
       
   184  * Called when all resources allocated by notifiers shoudl be freed.
       
   185  */
       
   186 void CRsfwNotPluginDlg::Release()
       
   187     {
       
   188     delete this;
       
   189     }
       
   190 
       
   191 /**
       
   192  * Called when a notifier is first loaded to allow any initial construction that is required.
       
   193  */
       
   194 MEikSrvNotifierBase2::TNotifierInfo CRsfwNotPluginDlg::RegisterL()
       
   195     {
       
   196     iInfo.iUid = KRsfwNotifierPluginUID;
       
   197     // Because there are some longer wait notes here, we use low priority 
       
   198     // (lower than ENotifierPriorityVLow). This allows e.g. VPN credentials dialog on
       
   199     // top of the "Connecting..." wait note.
       
   200     iInfo.iChannel = EAknNotifierChannelProgressDialog; 
       
   201     iInfo.iPriority = ENotifierPriorityVLow; 
       
   202     return iInfo;
       
   203     }
       
   204 
       
   205 /**
       
   206  * Return the priority a notifier takes and the channels it acts on.  The return value may be varied
       
   207  * at run-time.
       
   208  */
       
   209 MEikSrvNotifierBase2::TNotifierInfo CRsfwNotPluginDlg::Info() const
       
   210     {
       
   211     return iInfo;
       
   212     }
       
   213 
       
   214 /**
       
   215  * Start the notifier with data aBuffer and return an initial response.
       
   216  */
       
   217 TPtrC8 CRsfwNotPluginDlg::StartL(const TDesC8& /*aBuffer*/)
       
   218     {
       
   219     //Create and launch confirmation dialog using static function.
       
   220     //The function returns True when the OK button is pressed.
       
   221     return TPtrC8(NULL, 0);
       
   222     }
       
   223 
       
   224 void CRsfwNotPluginDlg::HandleAsyncRequestL()
       
   225     {
       
   226     // Load resource file
       
   227     CEikonEnv* eikEnv = CEikonEnv::Static();
       
   228     TFileName filename(KResourceFile); 
       
   229     RConeResourceLoader resLoader(*eikEnv);
       
   230     User::LeaveIfError(resLoader.Open(filename));
       
   231     CleanupClosePushL(resLoader);
       
   232 	TInt result;
       
   233     TBool okpressed = EFalse;
       
   234     switch(iMethod)
       
   235         {
       
   236         
       
   237         case TRsfwNotPluginRequest::EAuthenticationDlg:
       
   238             DEBUGSTRING16(("CRsfwNotPluginDlg::HandleAsyncRequestL EAuthenticationDlg"));
       
   239             okpressed = ShowAuthenticationDialogL();
       
   240             DEBUGSTRING16(("CRsfwNotPluginDlg::::ShowAuthenticationDialogL returned %d", okpressed));
       
   241             break;  
       
   242         case TRsfwNotPluginRequest::EUnavailableRetryDlg:
       
   243            DEBUGSTRING16(("CRsfwNotPluginDlg::HandleAsyncRequestL EUnavailableRetryDlg"));
       
   244             okpressed  = ShowUnavailableRetryNoteL();  
       
   245            break;
       
   246         case TRsfwNotPluginRequest::ESaveToDlg:
       
   247             DEBUGSTRING16(("CRsfwNotPluginDlg::HandleAsyncRequestL ESaveToDlg"));
       
   248             okpressed = ShowSaveToDlgL();
       
   249             break;
       
   250         case TRsfwNotPluginRequest::EConnectingDlg:
       
   251         case TRsfwNotPluginRequest::EFetchingDlg:
       
   252             ShowWaitNoteL();
       
   253             break;
       
   254         default:
       
   255             break;
       
   256             
       
   257         }
       
   258 
       
   259 // some message dialogs will be completed here, 
       
   260 // others from the DialogDismissedL callback
       
   261 if (iMethod  <=  TRsfwNotPluginRequest::EUnavailableRetryDlg) 
       
   262     {
       
   263     if(iCancelled)
       
   264         {
       
   265         iMessage.Complete(KErrCancel);
       
   266         }
       
   267     else
       
   268         {
       
   269         if(okpressed) 
       
   270             {
       
   271             if (iMethod == TRsfwNotPluginRequest::EAuthenticationDlg) 
       
   272                 {
       
   273                 iMessage.WriteL(iReplySlot, *iAuthRequest);
       
   274                 }
       
   275             else if (iMethod == TRsfwNotPluginRequest::ESaveToDlg) 
       
   276                 {
       
   277                 iMessage.WriteL(iReplySlot, *iSaveToRequest);
       
   278                 }
       
   279             
       
   280             result = KErrNone;
       
   281             }
       
   282         else 
       
   283             {
       
   284             result = KErrCancel;
       
   285             }
       
   286         iMessage.Complete(result);
       
   287         }
       
   288     }
       
   289 
       
   290     CleanupStack::PopAndDestroy(&resLoader);
       
   291 
       
   292     }
       
   293 
       
   294 /**
       
   295  * Start the notifier with data aBuffer.  aMessage should be completed when the notifier is deactivated.
       
   296  * May be called multiple times if more than one client starts the notifier.  The notifier is immediately
       
   297  * responsible for completing aMessage.
       
   298  */
       
   299 
       
   300 void CRsfwNotPluginDlg::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage)
       
   301     {
       
   302     if(iMethod != TRsfwNotPluginRequest::ENoMethod)
       
   303         {
       
   304         aMessage.Complete(KErrInUse);
       
   305         return;
       
   306         }
       
   307 
       
   308     Cleanup();
       
   309     
       
   310      // Read incoming parameters
       
   311     TRsfwNotPluginRequest params;
       
   312     TPckgC<TRsfwNotPluginRequest> pckg( params );
       
   313     pckg.Set( aBuffer );
       
   314     iMethod = pckg().iMethod;
       
   315     iDriveName = pckg().iDriveName;
       
   316    
       
   317     
       
   318     if (iMethod == TRsfwNotPluginRequest::EAuthenticationDlg) 
       
   319         {
       
   320         TRsfwAuthenticationDlgRequest authparams;
       
   321         TPckgC<TRsfwAuthenticationDlgRequest> authpckg( authparams );
       
   322         authpckg.Set( aBuffer );
       
   323             
       
   324         // read parameters
       
   325         iUserName = HBufC::NewL(KRsfwMaxUsernameLength);
       
   326         TPtr username = iUserName->Des();
       
   327         username.Append(authpckg().iUserName);
       
   328         iPassword = HBufC::NewL(KRsfwMaxPasswordLength);
       
   329         TPtr psswd= iPassword->Des();
       
   330         psswd.Append(authpckg().iPassword);           
       
   331         }
       
   332     else if (iMethod == TRsfwNotPluginRequest::ESaveToDlg)
       
   333         {
       
   334         TRsfwSaveToDlgRequest saveToparams;
       
   335         TPckgC<TRsfwSaveToDlgRequest> savepckg( saveToparams );
       
   336         savepckg.Set( aBuffer );
       
   337             
       
   338         // read parameters
       
   339         iFileName = HBufC::NewL(KMaxFileName);
       
   340         TPtr filename = iFileName->Des();
       
   341         filename.Append(savepckg().iFileName);
       
   342         iCacheDrive = savepckg().iCacheDrive;
       
   343         TLex lex(savepckg().iFileSize);
       
   344         lex.Val(iFileSize);
       
   345         }
       
   346    
       
   347    
       
   348     iMessage = aMessage; 
       
   349     iReplySlot = aReplySlot;
       
   350     iStatus = KRequestPending;
       
   351     TRequestStatus* status = &iStatus;
       
   352     SetActive();
       
   353     User::RequestComplete(status, KErrNone);
       
   354 
       
   355     }
       
   356 
       
   357 
       
   358 TBool CRsfwNotPluginDlg::ShowAuthenticationDialogL()
       
   359     {
       
   360     DEBUGSTRING16(("CRsfwNotPluginDlg::::ShowAuthenticationDialogL"));
       
   361     	  	
       
   362     TBool returnValue = EFalse;
       
   363 	HBufC* firstprompt = NULL;
       
   364 	HBufC* secondprompt = NULL;
       
   365     firstprompt = StringLoader::LoadLC( R_RD_QUERY_USERNAME, iDriveName );
       
   366 	DEBUGSTRING16(("loaded firstprompt"));
       
   367 	secondprompt = StringLoader::LoadLC( R_RD_QUERY_PASSWORD);	
       
   368 		
       
   369 	DEBUGSTRING16(("loaded secondprompt"));
       
   370 	iAuthRequest = new (ELeave) TRsfwAuthParamsPckg();
       
   371 	TPtr username = iUserName->Des();
       
   372     TPtr password = iPassword->Des();
       
   373     CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(username,password);
       
   374     CleanupStack::PushL(dlg);
       
   375     DEBUGSTRING16(("created dialog"));
       
   376     dlg->SetPromptL(*firstprompt, *secondprompt);
       
   377     DEBUGSTRING16(("set prompts"));
       
   378     CleanupStack::Pop(dlg);
       
   379     dlg->SetMaxLengthOfFirstEditor(KRsfwMaxUsernameLength);
       
   380     dlg->SetMaxLengthOfFirstEditor(KRsfwMaxPasswordLength);
       
   381     iDialog = dlg;
       
   382     
       
   383     BlockAppSwitching();
       
   384     TBool okButtonSelected = dlg->ExecuteLD(R_CUSTOM_USERNAMEPASSWD_DIALOG);
       
   385     UnblockAppSwitching();
       
   386 
       
   387     
       
   388     if (okButtonSelected) 
       
   389         {
       
   390         returnValue = ETrue;
       
   391         (*iAuthRequest)().iUserName = username;
       
   392         (*iAuthRequest)().iPassword = password;
       
   393         }
       
   394     
       
   395     CleanupStack::PopAndDestroy(2, firstprompt); // secondprompt, firstprompt
       
   396     return returnValue;
       
   397     
       
   398     }
       
   399     
       
   400 TBool CRsfwNotPluginDlg::ShowSaveToDlgL()
       
   401     { 
       
   402     
       
   403     TPtr filename = iFileName->Des();  
       
   404   
       
   405     CDesCArrayFlat* strings = new (ELeave) CDesCArrayFlat( 2 );
       
   406     CleanupStack::PushL( strings );
       
   407     strings->AppendL( filename );
       
   408     strings->AppendL( iDriveName );    
       
   409     
       
   410     TBool dialogCancelled = EFalse;
       
   411     TBool fileSelected = EFalse;
       
   412     iCurrentRootPath = HBufC::NewL(KMaxPath);
       
   413     TPtr rootptr = iCurrentRootPath->Des();
       
   414     TPtr folderptr(NULL, 0);
       
   415     
       
   416     TInt saveSelection;
       
   417     iSaveToRequest = new (ELeave) TRsfwSaveToParamsPckg();
       
   418     CAknQueryDialog* note = CAknQueryDialog::NewL();
       
   419     CleanupStack::PushL(note);
       
   420     HBufC* saveprompt = StringLoader::LoadLC( R_RD_FILE_SAVE_FAIL, *strings);
       
   421     note->SetPromptL(*saveprompt);
       
   422     CleanupStack::PopAndDestroy(saveprompt);
       
   423     CleanupStack::Pop(note);
       
   424 
       
   425     BlockAppSwitching();            
       
   426     saveSelection = note->ExecuteLD(R_CUSTOM_SAVE_QUERY);   
       
   427     UnblockAppSwitching();
       
   428 
       
   429     CleanupStack::PopAndDestroy(strings); // strings
       
   430    
       
   431     if (saveSelection == EAknSoftkeySave) 
       
   432         {    
       
   433         while (!fileSelected && !dialogCancelled)
       
   434             {
       
   435              CAknMemorySelectionDialog::TMemory selectedMem = 
       
   436                                             CAknMemorySelectionDialog::EPhoneMemory;
       
   437             if (iMemDialog) 
       
   438                 {
       
   439                 delete iMemDialog;
       
   440                 iMemDialog = NULL;
       
   441                 }  
       
   442                                           
       
   443              iMemDialog = CAknMemorySelectionDialog::NewL(ECFDDialogTypeSave, EFalse);
       
   444              CAknCommonDialogsBase::TReturnKey retvalue;
       
   445         
       
   446              iMemDialog->SetObserver(this);
       
   447              retvalue = iMemDialog->ExecuteL(selectedMem, &rootptr, &folderptr); 
       
   448              if (retvalue) 
       
   449                 {
       
   450                 CAknFileSelectionDialog* filedialog = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave);
       
   451                 CleanupStack::PushL(filedialog);
       
   452                 HBufC* dialogtxt = NULL;
       
   453                 dialogtxt = StringLoader::LoadLC( R_RD_SELECT_DIR_BACK );
       
   454                 filedialog->SetRightSoftkeyRootFolderL(*dialogtxt);
       
   455                 fileSelected = filedialog->ExecuteL(rootptr);
       
   456                 CleanupStack::PopAndDestroy(2, filedialog); // dialogtxt, filedialog
       
   457                 }
       
   458              else 
       
   459                 {
       
   460                 dialogCancelled = ETrue;
       
   461                 }
       
   462             }
       
   463         
       
   464         }
       
   465        else
       
   466         {
       
   467         dialogCancelled = ETrue;
       
   468         }
       
   469     
       
   470     if (!dialogCancelled) 
       
   471         {
       
   472         dialogCancelled = !GetValidNameL(rootptr, filename);
       
   473       
       
   474         }
       
   475     
       
   476     rootptr.Append(filename);    
       
   477     
       
   478     if (!dialogCancelled) 
       
   479         {
       
   480         (*iSaveToRequest)().iFileName= rootptr;
       
   481         }
       
   482                
       
   483         
       
   484     return !dialogCancelled;
       
   485     
       
   486     }
       
   487 
       
   488 void CRsfwNotPluginDlg::ShowWaitNoteL() 
       
   489     {
       
   490     if (iWaitDialog) 
       
   491         {
       
   492         delete iWaitDialog;
       
   493         iWaitDialog = NULL;
       
   494         }
       
   495       
       
   496       // We set visibilityDelayOff
       
   497       // As we show wait dialog only for remote operations
       
   498       // we can assumet that the length of the operation is always
       
   499      //  over 1.5 seconds..
       
   500       iWaitDialog = new( ELeave ) CAknWaitDialog(
       
   501             reinterpret_cast< CEikDialog** >( &iWaitDialog ),
       
   502             ETrue );
       
   503 
       
   504     
       
   505     // if user cancels the wait note, this is received via the callbakc.
       
   506     iWaitDialog->SetCallback(this);  
       
   507             
       
   508     switch (iMethod) 
       
   509         {
       
   510         case TRsfwNotPluginRequest::EConnectingDlg:
       
   511             // 'app key' will be unblocked in DialogDismissedL()
       
   512             BlockAppSwitching();
       
   513             iWaitDialog->ExecuteLD(R_CONNECTING_WAIT_NOTE);
       
   514             break;
       
   515         case TRsfwNotPluginRequest::EFetchingDlg:
       
   516             // 'app key' will be unblocked in DialogDismissedL()
       
   517             BlockAppSwitching();
       
   518             iWaitDialog->ExecuteLD(R_FETCHING_WAIT_NOTE); 
       
   519             break;
       
   520         }   
       
   521     }
       
   522     
       
   523 
       
   524 TBool CRsfwNotPluginDlg::ShowUnavailableRetryNoteL()
       
   525     {
       
   526     HBufC* retryprompt = NULL;
       
   527     retryprompt = StringLoader::LoadLC( R_RD_DRIVE_UNAVAILABLE, iDriveName );
       
   528     
       
   529     CAknQueryDialog* note = CAknQueryDialog::NewL();
       
   530     CleanupStack::PushL(note);
       
   531     note->SetPromptL(*retryprompt);
       
   532     CleanupStack::Pop(note);
       
   533 
       
   534     BlockAppSwitching();
       
   535     TBool retryButtonSelected = note->ExecuteLD(R_CUSTOM_RETRY_QUERY);    
       
   536     UnblockAppSwitching();    
       
   537 
       
   538     CleanupStack::PopAndDestroy(retryprompt);
       
   539     if (retryButtonSelected) 
       
   540         {
       
   541         return ETrue;
       
   542         }
       
   543     else 
       
   544         {
       
   545         return EFalse;
       
   546         }
       
   547     }
       
   548 
       
   549 
       
   550 
       
   551 TBool CRsfwNotPluginDlg::OkToExitL( CAknMemorySelectionDialog::TMemory aMemory ) 
       
   552     {
       
   553     TBool returnValue = EFalse;
       
   554     TPtr rootptr = iCurrentRootPath->Des();
       
   555     TPtr folderptr(NULL, 0);
       
   556     iMemDialog->GetMemories( aMemory, &rootptr, &folderptr);
       
   557   
       
   558     TDriveUnit selectedDrive(iCurrentRootPath[0]);
       
   559     TDriveUnit cacheDrive(iCacheDrive);
       
   560     if (selectedDrive == cacheDrive) 
       
   561         {
       
   562         // just move between one drive
       
   563         returnValue = ETrue;
       
   564         }
       
   565     else if (aMemory == CAknMemorySelectionDialog::EMemoryCard) 
       
   566         {
       
   567         if (SysUtil::MMCSpaceBelowCriticalLevelL(&iFs, iFileSize)) 
       
   568             {
       
   569             ShowDiskFullNoteL(EFalse);
       
   570             }
       
   571         else 
       
   572             {
       
   573             returnValue = ETrue;
       
   574             }
       
   575         }
       
   576     else if (aMemory == CAknMemorySelectionDialog::EPhoneMemory) 
       
   577         {
       
   578         if (SysUtil::FFSSpaceBelowCriticalLevelL(&iFs, iFileSize))
       
   579             {
       
   580             ShowDiskFullNoteL(ETrue);
       
   581             }
       
   582         else 
       
   583             {
       
   584             returnValue = ETrue;
       
   585             }
       
   586         }
       
   587      else 
       
   588         {
       
   589         // only allow memorycard or phone memory 
       
   590         returnValue = EFalse;
       
   591         }
       
   592     return returnValue;
       
   593     }
       
   594 
       
   595 TBool CRsfwNotPluginDlg::GetValidNameL(TDesC& aPath, TDes& aName)
       
   596     {
       
   597     HBufC* fullPath = HBufC::NewLC(KMaxFileName);
       
   598     TPtr pathPtr= fullPath->Des();
       
   599     pathPtr.Append(aPath);
       
   600     pathPtr.Append(aName);
       
   601     TBool renameFile = EFalse;
       
   602     TBool userCancelled = EFalse;
       
   603     TBool overwriteSelection = EFalse;
       
   604   
       
   605  
       
   606     while (BaflUtils::FileExists(iFs, pathPtr) && !userCancelled && !overwriteSelection) 
       
   607         {
       
   608         TUint32 fileType( 0 );
       
   609         fileType = FileTypeL( pathPtr ); 
       
   610         // returns KEntryAttReadOnly if file is read only or open
       
   611         CAknQueryDialog* note = CAknQueryDialog::NewL();
       
   612         CleanupStack::PushL(note);
       
   613         HBufC* queryprompt;
       
   614         if (fileType & KEntryAttReadOnly) 
       
   615             {
       
   616             TBool retValue;
       
   617             queryprompt = StringLoader::LoadLC( R_RD_ITEM_RENAME_QUERY, aName);
       
   618             note->SetPromptL(*queryprompt);
       
   619             CleanupStack::PopAndDestroy(queryprompt);
       
   620             CleanupStack::Pop(note);
       
   621             retValue = note->ExecuteLD(R_RSFW_PLUGIN_RENAME_QUERY);
       
   622             if (retValue) 
       
   623                 {
       
   624                 renameFile = ETrue;
       
   625                 }
       
   626             else 
       
   627                 {
       
   628                 userCancelled = ETrue;
       
   629                 }
       
   630             }
       
   631         else 
       
   632             {
       
   633             TBool retValue;
       
   634             queryprompt = StringLoader::LoadLC( R_RD_ITEM_OVERWRITE_QUERY, aName);
       
   635             note->SetPromptL(*queryprompt);
       
   636             CleanupStack::PopAndDestroy(queryprompt);
       
   637             CleanupStack::Pop(note);
       
   638             retValue = note->ExecuteLD(R_RSFW_PLUGIN_OVERWRITE_QUERY);  
       
   639             if (!retValue) 
       
   640                 {
       
   641                 renameFile = ETrue;
       
   642                 }
       
   643             else 
       
   644                 {
       
   645                 overwriteSelection = ETrue;
       
   646                 }
       
   647             }
       
   648         
       
   649         
       
   650         if (renameFile) 
       
   651             {
       
   652             TBool retval;
       
   653             CRsfwNotPluginNameDialog* dlg = 
       
   654                 CRsfwNotPluginNameDialog::NewL( 
       
   655                 pathPtr, aName, iFs);
       
   656             dlg->SetMaxLength(KMaxFileName - aPath.Length());
       
   657             dlg->PrepareLC( R_RSFW_NOT_PLUGIN_FILE_NAME_QUERY );
       
   658             retval = dlg->RunLD();
       
   659             if (!retval) 
       
   660                 {
       
   661                 userCancelled = ETrue;
       
   662                 }
       
   663             else 
       
   664                 {
       
   665                 // reset the path after user renamed the file
       
   666                 CleanupStack::PopAndDestroy(fullPath);
       
   667                 fullPath = HBufC::NewLC(KMaxFileName);
       
   668                 pathPtr= fullPath->Des();
       
   669                 pathPtr.Append(aPath);
       
   670                 pathPtr.Append(aName);
       
   671                 }
       
   672             }
       
   673         
       
   674         }
       
   675     
       
   676     CleanupStack::PopAndDestroy(fullPath);   
       
   677         
       
   678     if (!userCancelled) 
       
   679         {
       
   680         return ETrue;
       
   681         }
       
   682     else 
       
   683         {
       
   684         return EFalse;
       
   685         }
       
   686     
       
   687  
       
   688     }
       
   689 
       
   690 
       
   691 
       
   692 
       
   693 // ---------------------------------------------------------
       
   694 // CRsfwNotPluginDlg::ShowDiskFullNoteL
       
   695 // Show an out of disk note.
       
   696 // ---------------------------------------------------------
       
   697 //
       
   698 void CRsfwNotPluginDlg::ShowDiskFullNoteL( TBool aInternal )
       
   699     {
       
   700 
       
   701     HBufC* message = NULL;
       
   702 
       
   703     if ( aInternal )
       
   704         {
       
   705         message = StringLoader::LoadLC( R_RSFWPLUGIN_NOT_ENOUGH_MEMORY );
       
   706         }
       
   707     else
       
   708         {
       
   709         message = StringLoader::LoadLC( R_RSFWPLUGIN_MMC_NOT_ENOUGH_MEMORY );
       
   710         }
       
   711 
       
   712     TRequestStatus status = KErrNone;
       
   713 	CAknGlobalNote* note = CAknGlobalNote::NewL();
       
   714     CleanupStack::PushL( note );
       
   715     note->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY );
       
   716 	note->ShowNoteL( status, EAknGlobalErrorNote, *message );
       
   717     User::WaitForRequest( status );
       
   718 
       
   719     CleanupStack::PopAndDestroy( 2, message ); // note, message
       
   720     }
       
   721 
       
   722 
       
   723 // ---------------------------------------------------------------------------
       
   724 // The notifier has been deactivated so resources can be freed and outstanding messages completed.
       
   725 // ---------------------------------------------------------------------------
       
   726 //
       
   727 void CRsfwNotPluginDlg::Cancel()
       
   728     {
       
   729     DEBUGSTRING(("CRsfwNotPluginDlg::Cancel"));        
       
   730     TRAP_IGNORE(CancelL()); 
       
   731     DEBUGSTRING(("exiting CRsfwNotPluginDlg::Cancel"));
       
   732     }
       
   733 
       
   734 // ---------------------------------------------------------------------------
       
   735 // Called by Cancel() in order to catch the possible leaves.
       
   736 // ---------------------------------------------------------------------------
       
   737 //
       
   738 void CRsfwNotPluginDlg::CancelL()
       
   739     {
       
   740     if ((iMethod  >=  TRsfwNotPluginRequest::EConnectingDlg) &&
       
   741         iWaitDialog) 
       
   742         {
       
   743         DEBUGSTRING(("calling ProcessFinishedL()"));
       
   744         iDialogDismissedCalled = EFalse;
       
   745         iWaitDialog->ProcessFinishedL();
       
   746         // iWaitDialog->ProcessFinishedL() should call 
       
   747         // dialogdismissed, but for some reason this does not always
       
   748         // happen (really looks and feels like a )
       
   749         // this extra help should save the day
       
   750         if (!iDialogDismissedCalled) 
       
   751             {
       
   752             DEBUGSTRING(("extra call to ProcessFinishedL()"));
       
   753             DialogDismissedL(EAknSoftkeyDone);
       
   754             }
       
   755         }
       
   756     Cleanup();
       
   757     }
       
   758 
       
   759 // ---------------------------------------------------------------------------
       
   760 // Sets KEntryAttReadOnly if the file is read only, system or open
       
   761 // ---------------------------------------------------------------------------
       
   762 //
       
   763 TUint32 CRsfwNotPluginDlg::FileTypeL( const TDesC& aFullPath ) const
       
   764     {
       
   765     TUint32 fileType(0);
       
   766  // Full check for local and removable drives
       
   767     TEntry entry;
       
   768     TInt err( iFs.Entry( aFullPath, entry ) );
       
   769 
       
   770     // Check if item was deleted outside this component
       
   771     if ( err == KErrNotFound || err == KErrPathNotFound )
       
   772         {
       
   773         User::Leave( err );
       
   774         }
       
   775 
       
   776     TBool fileOpen( EFalse );
       
   777     iFs.IsFileOpen( aFullPath, fileOpen );
       
   778     if ( fileOpen || entry.IsReadOnly() || entry.IsSystem() )
       
   779         {
       
   780         fileType |= KEntryAttReadOnly;
       
   781         }
       
   782                 
       
   783     return fileType;            
       
   784             
       
   785     }
       
   786     
       
   787 // ---------------------------------------------------------------------------
       
   788 // Update a currently active notifier with data aBuffer.
       
   789 // ---------------------------------------------------------------------------
       
   790 //
       
   791 TPtrC8 CRsfwNotPluginDlg::UpdateL(const TDesC8& /*aBuffer*/)
       
   792     {
       
   793     return TPtrC8(NULL, 0);
       
   794     }
       
   795 
       
   796 
       
   797 void CRsfwNotPluginDlg::DialogDismissedL( TInt aButtonId )
       
   798     {
       
   799     DEBUGSTRING(("CRsfwNotPluginDlg::DialogDismissedL"));
       
   800     iDialogDismissedCalled = ETrue;
       
   801     
       
   802     UnblockAppSwitching();
       
   803     
       
   804     if (aButtonId == EAknSoftkeyCancel) 
       
   805         {
       
   806         DEBUGSTRING(("Completing dialogrequest with KErrCancel"));
       
   807         iMessage.Complete(KErrCancel);
       
   808         }
       
   809     else if (aButtonId == EAknSoftkeyDone) 
       
   810         {
       
   811         DEBUGSTRING(("Completing dialogrequest with KErrNone"));
       
   812         iMessage.Complete(KErrNone);
       
   813         }
       
   814     else 
       
   815         {
       
   816         DEBUGSTRING16(("Completing dialogrequest with %d", aButtonId));
       
   817         iMessage.Complete(aButtonId);
       
   818         }
       
   819     }
       
   820 
       
   821 // ---------------------------------------------------------------------------
       
   822 // CRsfwNotPluginDlg::BlockAppSwitching
       
   823 // Temporarily disables 'app key', so that user cannot switch or close
       
   824 // the app when global dialog is being displayed
       
   825 // ---------------------------------------------------------------------------
       
   826 //
       
   827 void CRsfwNotPluginDlg::BlockAppSwitching( )
       
   828     {
       
   829     if ( !iAppSwitchingBlocked )
       
   830         {
       
   831         ((CEikServAppUi*)(CEikonEnv::Static())->EikAppUi())
       
   832        	         ->SuppressAppSwitching(ETrue);
       
   833        	iAppSwitchingBlocked = ETrue;
       
   834         }
       
   835     }
       
   836 
       
   837 // ---------------------------------------------------------------------------
       
   838 // CRsfwNotPluginDlg::UnblockAppSwitching
       
   839 // Enables 'app key' back
       
   840 // ---------------------------------------------------------------------------
       
   841 //
       
   842 void CRsfwNotPluginDlg::UnblockAppSwitching( )
       
   843     {
       
   844     if ( iAppSwitchingBlocked )
       
   845         {
       
   846         ((CEikServAppUi*)(CEikonEnv::Static())->EikAppUi())
       
   847        	         ->SuppressAppSwitching(EFalse);
       
   848        	iAppSwitchingBlocked = EFalse;
       
   849         }
       
   850     }
       
   851 
       
   852 // ---------------------------------------------------------------------------
       
   853 // ECOM interface
       
   854 // ---------------------------------------------------------------------------
       
   855 //
       
   856 const TImplementationProxy ImplementationTable[] =
       
   857 	{
       
   858 
       
   859 	IMPLEMENTATION_PROXY_ENTRY(0x101F9772,NotifierArray)
       
   860 
       
   861 	};
       
   862 
       
   863 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   864 	{
       
   865 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy) ;
       
   866 	return ImplementationTable;
       
   867 	}
       
   868