menufw/hierarchynavigator/hnmetadatamodel/src/hnmdnotifyrequest.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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <xmlengelement.h> 
       
    20 #include <xmlengdom.h>
       
    21 
       
    22 #include "hnmdbasekey.h"
       
    23 #include "hnmdmodel.h"
       
    24 #include "hnservicehandler.h"
       
    25 #include "hnmdservicecommand.h"
       
    26 #include "hnitemid.h"
       
    27 #include "hnmdnotifyrequest.h"
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // 
       
    31 // ---------------------------------------------------------------------------
       
    32 // 
       
    33 CHnMdNotifyRequest* CHnMdNotifyRequest::NewL( TXmlEngElement aElement, 
       
    34         const CHnItemId & aItemId, THnMdCommonPointers* aCmnPtrs )
       
    35         
       
    36     {
       
    37     CHnMdNotifyRequest* self = CHnMdNotifyRequest::NewLC(aElement,
       
    38             aItemId, aCmnPtrs );
       
    39     CleanupStack::Pop();
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // 
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CHnMdNotifyRequest* CHnMdNotifyRequest::NewLC( TXmlEngElement aElement,
       
    48         const CHnItemId & aItemId, THnMdCommonPointers* aCmnPtrs )
       
    49     {
       
    50     CHnMdNotifyRequest* self = new (ELeave) CHnMdNotifyRequest( aCmnPtrs );
       
    51     CleanupStack::PushL(self);
       
    52     self->ConstructL( aElement, aItemId );
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // 
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CHnMdNotifyRequest::~CHnMdNotifyRequest()
       
    61     {
       
    62     delete iItemId;
       
    63     delete iService;
       
    64     delete iSh;
       
    65     }
       
    66  
       
    67 // ---------------------------------------------------------------------------
       
    68 // 
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CHnMdNotifyRequest::ConstructL( TXmlEngElement aElement, 
       
    72         const CHnItemId & aItemId )
       
    73     {
       
    74     ASSERT(aElement.Name() == KNotifyRequestElementName8 );
       
    75 
       
    76     iItemId = CHnItemId::NewL( aItemId.SuiteName(), aItemId.Id() );
       
    77     iService = CHnMdService::NewL( aElement );
       
    78     iSh = NULL;
       
    79     }
       
    80     
       
    81 // ---------------------------------------------------------------------------
       
    82 // 
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CHnMdNotifyRequest::CHnMdNotifyRequest(THnMdCommonPointers* aCmnPtrs) 
       
    86     : iCmnPtrs(aCmnPtrs)
       
    87     {
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // 
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CHnMdNotifyRequest::RequestNotifyL( CLiwGenericParamList& aParams, 
       
    95         TInt aCmdOptions )
       
    96     {
       
    97     if ( iSh == NULL )
       
    98         {
       
    99         CLiwGenericParamList* constructor =
       
   100             iService->EvaluateConstructorL( aParams );
       
   101         CleanupStack::PushL(constructor);
       
   102         CLiwGenericParamList* command = iService->EvaluateCommandL( aParams );
       
   103         CleanupStack::PushL( command );
       
   104     
       
   105         // Create service
       
   106         iSh = CHnServiceHandler::NewL( 
       
   107                 iService->GetServiceName(), 
       
   108                 iService->GetInterfaceName(), 
       
   109                 iService->GetCommand().GetCommandName(),
       
   110                 EServiceModeAsynchronous,
       
   111                 constructor, 
       
   112                 command );
       
   113     
       
   114         CleanupStack::Pop( command );
       
   115         CleanupStack::Pop( constructor );
       
   116         }
       
   117     iSh->ExecuteL( this, aCmdOptions ); 
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // 
       
   122 // ---------------------------------------------------------------------------
       
   123 //     
       
   124 TInt CHnMdNotifyRequest::HandleNotifyL( TInt /* aCmdId */, TInt aEventId ,
       
   125         CLiwGenericParamList& /* aEventParamList */,
       
   126         const CLiwGenericParamList& /* aInParamList */)
       
   127     {
       
   128     TInt err( KErrNone );
       
   129     
       
   130     if ( aEventId == KLiwEventInProgress )
       
   131         {
       
   132         //Filling in variant structure.
       
   133         CLiwGenericParamList* inParam = CLiwGenericParamList::NewL();
       
   134         CleanupStack::PushL( inParam );
       
   135            
       
   136         CLiwDefaultMap* map = CLiwDefaultMap::NewLC();
       
   137             
       
   138         map->InsertL( KGenreName8, TLiwVariant(iItemId->SuiteName()) );
       
   139         map->InsertL( KItemName8, TLiwVariant(iItemId->Id()) );
       
   140         
       
   141         CLiwDefaultList* list = CLiwDefaultList::NewLC();   
       
   142         
       
   143         list->AppendL( TLiwVariant( map ) );
       
   144         inParam->AppendL(TLiwGenericParam( KFilterElementItem8, TLiwVariant(list)));
       
   145         CleanupStack::PopAndDestroy( list );
       
   146         CleanupStack::PopAndDestroy( map );
       
   147         
       
   148         iCmnPtrs->iModelEventObserver->HandleModelEventL( KReevaluateMdEvent, *inParam );
       
   149     
       
   150         CleanupStack::PopAndDestroy( inParam );
       
   151         }
       
   152     
       
   153     return err;
       
   154     }
       
   155