|
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: action model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <liwcommon.h> |
|
20 |
|
21 #include "hnmdaction.h" |
|
22 #include "hnmdkeyfactory.h" |
|
23 #include "hnmdbasekey.h" |
|
24 #include "hnconditionfactory.h" |
|
25 #include "hnmdservicecommand.h" |
|
26 #include "hnactionmodel.h" |
|
27 #include "hnmdservice.h" |
|
28 #include "hnconditioninterface.h" |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 void CHnMdAction::ConstructL( TXmlEngElement aElement ) |
|
35 { |
|
36 ASSERT( aElement.Name() == KActionElementName8 ); |
|
37 |
|
38 iService = CHnMdService::NewL( aElement ); |
|
39 |
|
40 if( aElement.AttributeValueL( KMenuConditionAttrName8 ).Length() ) |
|
41 { |
|
42 SetConditionL( aElement.AttributeNodeL( KMenuConditionAttrName8 ) ); |
|
43 } |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CHnMdAction* CHnMdAction::NewL( TXmlEngElement aElement ) |
|
52 { |
|
53 CHnMdAction* self = CHnMdAction::NewLC( aElement ); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CHnMdAction* CHnMdAction::NewLC( TXmlEngElement aElement ) |
|
64 { |
|
65 CHnMdAction* self = new( ELeave ) CHnMdAction; |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL( aElement ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CHnMdAction::CHnMdAction() |
|
77 { |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CHnMdAction::~CHnMdAction() |
|
85 { |
|
86 delete iService; |
|
87 delete iCondition; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CHnMdAction::SetConditionL( TXmlEngAttr aAttr ) |
|
95 { |
|
96 iCondition = HnConditionFactory::NewL( aAttr ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CHnMdAction::EvaluateL( CHnActionModel* aActionModel, |
|
104 const CLiwGenericParamList& aQueriesResultsList, TInt aPos) |
|
105 { |
|
106 TInt ret( KErrNone ); |
|
107 |
|
108 aActionModel->SetServiceL( iService->GetServiceName() ); |
|
109 aActionModel->SetInterfaceL( iService->GetInterfaceName() ); |
|
110 aActionModel->SetCommandNameL( iService->GetCommand().GetCommandName() ); |
|
111 aActionModel->SetServiceModeL( iService->GetCommand().GetCommandMode() ); |
|
112 aActionModel->SetConstructorL( |
|
113 iService->EvaluateConstructorAsKeyL( aQueriesResultsList, aPos ) ); |
|
114 aActionModel->SetCommand( |
|
115 iService->EvaluateCommandAsKeyL( aQueriesResultsList, aPos ) ); |
|
116 return ret; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CHnMdAction::IsValidL( const CLiwGenericParamList& aQueryResults, |
|
124 TInt aPos ) |
|
125 { |
|
126 TBool ret( EFalse ); |
|
127 if( !iCondition || iCondition->ResultL( aQueryResults, aPos ) ) |
|
128 { |
|
129 ret = ETrue; |
|
130 } |
|
131 return ret; |
|
132 } |
|
133 |