remotestoragefw/rsfwnotifierplugins/src/rsfwnotpluginnamedialog.cpp
changeset 0 3ad9d5175a89
equal deleted inserted replaced
-1:000000000000 0:3ad9d5175a89
       
     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:  File name query dialog for "save as" dialog
       
    15 *
       
    16 */
       
    17 
       
    18 // ============================ MEMBER FUNCTIONS ===============================
       
    19 
       
    20 #include <rsfwnotplugindlg.rsg>
       
    21 #include <StringLoader.h>
       
    22 #include <aknnotewrappers.h>
       
    23 #include <bautils.h>
       
    24 #include "rsfwnotpluginnamedialog.h"
       
    25 
       
    26 // Left to right and right to left markers
       
    27 _LIT( KDirectionalChars, "\x202A\x202B\x202C\x202D\x200E\x200F" );
       
    28 
       
    29 
       
    30 
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CRsfwNotPluginNameDialog::NewL
       
    34 // 
       
    35 // -----------------------------------------------------------------------------
       
    36 // 
       
    37 EXPORT_C CRsfwNotPluginNameDialog* CRsfwNotPluginNameDialog::NewL(
       
    38         const TDesC& aOldName,
       
    39         TDes& aNewName,
       
    40         RFs& aFs)
       
    41 	{
       
    42 	CRsfwNotPluginNameDialog* self =
       
    43 	    new( ELeave ) CRsfwNotPluginNameDialog(
       
    44 	        aNewName, aFs);
       
    45 	
       
    46 	CleanupStack::PushL( self );
       
    47 	self->ConstructL( aOldName );
       
    48 	CleanupStack::Pop( self );
       
    49 
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CRsfwNotPluginNameDialog::CRsfwNotPluginNameDialog
       
    55 // C++ default constructor can NOT contain any code, that
       
    56 // might leave.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CRsfwNotPluginNameDialog::CRsfwNotPluginNameDialog(
       
    60         TDes& aNewName, RFs& aFs ) : 
       
    61         CAknTextQueryDialog( aNewName ), iFs(aFs)
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CRsfwNotPluginNameDialog::ConstructL
       
    67 // 
       
    68 // -----------------------------------------------------------------------------
       
    69 // 
       
    70 void CRsfwNotPluginNameDialog::ConstructL( const TDesC& aOldName )
       
    71 	{
       
    72     TParsePtrC name( aOldName );
       
    73 	Text().Copy( name.NameAndExt() );
       
    74     iOldName = aOldName.AllocL();
       
    75 
       
    76     // Strip any directionality markers to get pure name
       
    77     TPtr ptr( iOldName->Des() );
       
    78     AknTextUtils::StripCharacters( ptr, KDirectionalChars );
       
    79 	}
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CRsfwNotPluginNameDialog::~CRsfwNotPluginNameDialog
       
    83 // Destructor
       
    84 // -----------------------------------------------------------------------------
       
    85 // 
       
    86 CRsfwNotPluginNameDialog::~CRsfwNotPluginNameDialog()
       
    87     {
       
    88     delete iOldName;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CRsfwNotPluginNameDialog::OkToExitL
       
    93 // 
       
    94 // -----------------------------------------------------------------------------
       
    95 // 
       
    96 TBool CRsfwNotPluginNameDialog::OkToExitL( TInt aButtonId )
       
    97     {
       
    98     TBool result( CAknTextQueryDialog::OkToExitL( aButtonId ) );
       
    99 
       
   100     HBufC* userText = Text().AllocLC();
       
   101     TPtr ptrUserText( userText->Des() );
       
   102 
       
   103     // Strip any directionality markers to get pure name
       
   104     AknTextUtils::StripCharacters( ptrUserText, KDirectionalChars );
       
   105 
       
   106     // Check file name
       
   107     TBool isValidName( EFalse );
       
   108     TText badChar(NULL);
       
   109     isValidName = iFs.IsValidName(*userText, badChar);
       
   110    
       
   111         
       
   112 	if( !isValidName )
       
   113         {
       
   114         TBuf<5> dotbuf;
       
   115         dotbuf.Append(KDot);
       
   116         TChar dot(dotbuf[0]);
       
   117         if (badChar == dot)
       
   118             {
       
   119             // dot is a special case, as "." or ".." are illegal file names
       
   120             // but for example "file.name" is not, and thus dot is not mentioned
       
   121             // in R_RD_FLDR_ILLEGAL_CHARACTERS
       
   122             ShowSimpleInfoNoteL(R_RD_FLDR_BAD_FILE_NAME );
       
   123             }
       
   124         else 
       
   125             {
       
   126             ShowSimpleInfoNoteL(R_RD_FLDR_ILLEGAL_CHARACTERS );
       
   127             }
       
   128        
       
   129         CAknQueryControl* queryControl = QueryControl();
       
   130         if (queryControl)
       
   131             {
       
   132             CEikEdwin* edwin = static_cast< CEikEdwin* >(
       
   133                 queryControl->ControlByLayoutOrNull( EDataLayout ) );
       
   134             if (edwin)
       
   135                 {
       
   136                 edwin->SetSelectionL( edwin->TextLength(), 0 );
       
   137                 }
       
   138             }
       
   139         CleanupStack::PopAndDestroy( userText );
       
   140         return EFalse;
       
   141         }
       
   142     CleanupStack::PopAndDestroy( userText );
       
   143     return result;
       
   144     
       
   145     }
       
   146     
       
   147 
       
   148 // ------------------------------------------------------------------------------
       
   149 // CRsfwNotPluginNameDialog::ShowSimpleInfoNoteL
       
   150 //
       
   151 // ------------------------------------------------------------------------------
       
   152 //
       
   153 void CRsfwNotPluginNameDialog::ShowSimpleInfoNoteL(
       
   154         const TInt aTextId)
       
   155     {
       
   156     HBufC* text = NULL;
       
   157     text = StringLoader::LoadLC( aTextId );
       
   158     CAknInformationNote* dlg = new(ELeave) CAknInformationNote( ETrue );
       
   159     dlg->ExecuteLD( *text );
       
   160     CleanupStack::PopAndDestroy( text );
       
   161     }
       
   162 
       
   163 
       
   164