menufw/menufwui/mmextensions/mmfolderuiextension/src/mmfoldercommandrename.cpp
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   Rename folder command
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19  
       
    20 #include <liwcommon.h>
       
    21 
       
    22 #include "mmfoldercommandrename.h"
       
    23 #include "mmactionrequest.h"
       
    24 #include "hnglobals.h"
       
    25 #include "menudebug.h"
       
    26 #include "hnconvutils.h"
       
    27 #include "hnmdbasekey.h"
       
    28 #include "hnmdkeyfactory.h"
       
    29 #include "menudebug.h"
       
    30 #include "hnservicehandler.h"
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS =============================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // Symbian factory function.
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CMmFolderCommandRename* CMmFolderCommandRename::NewL()
       
    39 	{
       
    40 	CMmFolderCommandRename* self = new( ELeave ) CMmFolderCommandRename();
       
    41 	CleanupStack::PushL( self );
       
    42 	self->ConstructL();
       
    43 	CleanupStack::Pop( self );
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Symbian second phase constructor.
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void CMmFolderCommandRename::ConstructL()
       
    53 	{
       
    54 	BaseConstructL();
       
    55 	}
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // Destructor.
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CMmFolderCommandRename::~CMmFolderCommandRename()
       
    62 	{
       
    63 	delete iServiceHandler;
       
    64 	}
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // 
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CMmFolderCommandRename::CMmFolderCommandRename()
       
    71 	{
       
    72 	}
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 TInt CMmFolderCommandRename::HandleNotifyL( TInt /*aCmdId*/, 
       
    79                                 TInt /*aEventId*/,
       
    80                                 CLiwGenericParamList& /*aEventParamList*/,
       
    81                                 const CLiwGenericParamList& /*aInParamList*/ )
       
    82     {  
       
    83     MMPERF(("CFolderUiExtPlugin::RenameFolderCommandL - END"));
       
    84 	return KErrNone;
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // 
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 void CMmFolderCommandRename::ExecuteActionL( 
       
    92                                         CLiwGenericParamList* aEventParamList )
       
    93     {
       
    94   	MMPERF(("CFolderUiExtPlugin::RenameFolderCommandL - START"));
       
    95     TInt id = GetIntL( *aEventParamList, KIdAttrName8 );
       
    96     TPtrC currentName = GetStringL( *aEventParamList, KName8 );
       
    97     
       
    98     RBuf folder;
       
    99     CleanupClosePushL( folder );
       
   100     folder.CreateL( KMaxFileName );
       
   101     folder.Copy( currentName );
       
   102 
       
   103     MMPERF(("\t Show dialog"));
       
   104     TInt changed( KErrNone);
       
   105     TInt allowed( EValidationInvalid );
       
   106     do
       
   107         {
       
   108         changed = GetFolderNameL( folder );
       
   109         if (changed && folder.Length() > 0)
       
   110             {
       
   111             allowed = FolderNameValidationL( folder );
       
   112             }
       
   113         }
       
   114     while (allowed != EValidationOk && changed);
       
   115     
       
   116 	if( changed && allowed == EValidationOk )
       
   117         {
       
   118         MMPERF(("\t\t Rename folder - START"));
       
   119         RenameFolderL( id , folder );
       
   120         CLiwGenericParamList* list = CLiwGenericParamList::NewLC();
       
   121         TLiwGenericParam command( KHnRequest, TLiwVariant( KDisableActionsForItem ) );
       
   122         TLiwGenericParam itemCustomId(
       
   123                 KItemCustomId8, TLiwVariant( static_cast<TInt32>( id ) ) );
       
   124         list->AppendL( itemCustomId );
       
   125         list->AppendL( command );
       
   126         iActionRequest->HandleRequestL( *list );
       
   127         CleanupStack::PopAndDestroy( list );        
       
   128         MMPERF(("\t\t Rename folder - END"));
       
   129         }
       
   130 
       
   131 	CleanupStack::PopAndDestroy( &folder );
       
   132     }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // 
       
   136 // ---------------------------------------------------------------------------
       
   137 // 
       
   138 void CMmFolderCommandRename::RenameFolderL( TInt aId, RBuf& aFolderName )
       
   139     {
       
   140     HBufC8* id = HnConvUtils::NumToStr8LC( aId );
       
   141     
       
   142     CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL(
       
   143             KInData8, KKeyTypeMap, KDefaultParentId );
       
   144     CleanupStack::PushL( inDataKey );
       
   145     
       
   146     AddSubKeyL( inDataKey, KIdParam, KKeyTypeInteger, *id );
       
   147     AddSubKeyL( inDataKey, KMcsTitleName8, KKeyTypeString, aFolderName );
       
   148     AddSubKeyL( inDataKey, KMcsShortName8, KKeyTypeString, aFolderName );
       
   149     AddSubKeyL( inDataKey, KMcsLongName8, KKeyTypeString, aFolderName );
       
   150     
       
   151 	MCSQueryExecutionL( KCmdAdd8, inDataKey, NULL, this );
       
   152 
       
   153     CleanupStack::PopAndDestroy( inDataKey );
       
   154     CleanupStack::PopAndDestroy( id );
       
   155     }
       
   156 	
       
   157 // end of file
       
   158