menufw/menufwui/mmextensions/mmfolderuiextension/src/mmfoldercommandadd.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:  Add folder command
       
    15  *  Version     : %version: 19.1.7 % << Don't touch! Updated by Synergy at check-out.
       
    16  *
       
    17 */
       
    18 
       
    19  
       
    20 #include <liwcommon.h>
       
    21 
       
    22 #include "mmfoldercommandadd.h"
       
    23 #include "hnglobals.h"
       
    24 #include "menudebug.h"
       
    25 #include "hnconvutils.h"
       
    26 
       
    27 #include "hnmdbasekey.h"
       
    28 #include "hnmdkeyfactory.h"
       
    29 #include "menudebug.h"
       
    30 #include "mmactionrequest.h"
       
    31 #include "hnservicehandler.h"
       
    32 
       
    33 _LIT8( KItemLock, "item_lock" );
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS =============================
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // Symbian factory function.
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CMmFolderCommandAdd* CMmFolderCommandAdd::NewL()
       
    42 	{
       
    43 	CMmFolderCommandAdd* self = new( ELeave ) CMmFolderCommandAdd();
       
    44 	CleanupStack::PushL( self );
       
    45 	self->ConstructL();
       
    46 	CleanupStack::Pop( self );
       
    47 	return self;
       
    48 	}
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // Symbian second phase constructor.
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CMmFolderCommandAdd::ConstructL()
       
    56 	{
       
    57 	BaseConstructL();
       
    58 	}
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Destructor.
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CMmFolderCommandAdd::~CMmFolderCommandAdd()
       
    65 	{
       
    66 	delete iServiceHandler;
       
    67 	}
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // 
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CMmFolderCommandAdd::CMmFolderCommandAdd()
       
    74 	{
       
    75 	}
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // 
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 TInt CMmFolderCommandAdd::HandleNotifyL( TInt /*aCmdId*/, 
       
    82                                 TInt aEventId,
       
    83                                 CLiwGenericParamList& aEventParamList,
       
    84                                 const CLiwGenericParamList& /*aInParamList*/ )
       
    85     {  
       
    86     if( aEventId != KLiwEventCanceled )
       
    87         {	
       
    88 	    TInt pos( 0 );
       
    89         aEventParamList.FindFirst( pos, KIdAttrName8 );
       
    90         if (pos != KErrNotFound)
       
    91             {   
       
    92             CLiwGenericParamList* list = CLiwGenericParamList::NewLC();
       
    93             TLiwGenericParam command( KHnRequest, TLiwVariant( KSetFocus ) );
       
    94             TLiwGenericParam dataId(
       
    95                     KItemCustomId8, aEventParamList[pos].Value() );
       
    96             TLiwGenericParam dataParentId(
       
    97                     KSuiteCustomId8, TLiwVariant( iParent ) );
       
    98                       
       
    99             list->AppendL( dataId );
       
   100             list->AppendL( dataParentId );
       
   101             list->AppendL( command );
       
   102             
       
   103             iActionRequest->HandleRequestL( *list );
       
   104             CleanupStack::PopAndDestroy( list );
       
   105             }
       
   106 	    MMPERF(("CFolderUiExtPlugin::AddFolderCommandL - END"));
       
   107 		}
       
   108     return KErrNone;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CMmFolderCommandAdd::ExecuteAddFolderL()
       
   116 	{
       
   117     MMPERF(("\t Show dialog - START"));
       
   118     RBuf folder;
       
   119     CleanupClosePushL( folder );
       
   120     folder.CreateL( KMaxFileName );    
       
   121     
       
   122     TInt changed( KErrNone);
       
   123     TInt allowed( EValidationInvalid );
       
   124     do
       
   125         {
       
   126         changed = GetFolderNameL(folder, iGetListOutParam);
       
   127         if (changed && folder.Length() > 0)
       
   128             {
       
   129             allowed = FolderNameValidationL(folder, iGetListOutParam);
       
   130             }
       
   131         }
       
   132     while (allowed != EValidationOk && changed);
       
   133     MMPERF(("\t Show Dialog - END"));
       
   134     if (changed && allowed == EValidationOk)
       
   135         {
       
   136         MMPERF(("\t\t Create folder - START"));
       
   137         CreateFolderL( folder );
       
   138         MMPERF(("\t\t Create folder - END"));
       
   139         }
       
   140     CleanupStack::PopAndDestroy( &folder );
       
   141 	}
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // 
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 void CMmFolderCommandAdd::ExecuteActionL( 
       
   148                                        CLiwGenericParamList* aEventParamList )
       
   149     {
       
   150 	MMPERF(("CFolderUiExtPlugin::AddFolderCommandL - START"));
       
   151 	ASSERT( aEventParamList );
       
   152 	TBool lock = GetBoolL( *aEventParamList, KItemLock );
       
   153 	if( !lock )
       
   154 	    {
       
   155 	    iParent = GetIntL( *aEventParamList, KItemTypeFolder8 );
       
   156 	    GetFolderListL( iParent );
       
   157 	    ExecuteAddFolderL();
       
   158 	    }
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // 
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CMmFolderCommandAdd::CreateFolderL( const TDesC& aFolder )
       
   166 
       
   167     {
       
   168 	HBufC8* parentTemp = HnConvUtils::NumToStr8LC( iParent );
       
   169 
       
   170     CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL(
       
   171         KInData8, KKeyTypeMap, KDefaultParentId );
       
   172     CleanupStack::PushL( inDataKey );
       
   173 
       
   174     AddSubKeyL( inDataKey, KType8, KKeyTypeString, KMenuFolder8 );
       
   175     AddSubKeyL( inDataKey, KDeleteLocked8, KKeyTypeBoolean, KStringFalse8 );
       
   176     AddSubKeyL( inDataKey, KMcsAppGroupName8, KKeyTypeString, aFolder );
       
   177     AddSubKeyL( inDataKey, KMcsTitleName8, KKeyTypeString, aFolder );
       
   178     AddSubKeyL( inDataKey, KMcsShortName8, KKeyTypeString, aFolder );
       
   179     AddSubKeyL( inDataKey, KMcsLongName8, KKeyTypeString, aFolder );
       
   180     AddSubKeyL( inDataKey, KParentId8, KKeyTypeInteger, *parentTemp );
       
   181 
       
   182     MCSQueryExecutionL( KCmdAdd8, inDataKey, NULL, this );
       
   183 
       
   184     CleanupStack::PopAndDestroy( inDataKey );
       
   185     CleanupStack::PopAndDestroy( parentTemp );
       
   186     }
       
   187 	
       
   188 // end of file
       
   189