|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 PoC command object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2PocCmd.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "CPbk2CallTypeSelector.h" |
|
23 #include <Pbk2UID.h> |
|
24 #include <MPbk2ContactUiControl.h> |
|
25 #include <Pbk2Commands.hrh> |
|
26 |
|
27 // Virtual Phonebook |
|
28 #include <CVPbkContactLinkArray.h> |
|
29 #include <MVPbkStoreContact.h> |
|
30 |
|
31 // System includes |
|
32 #include <AiwServiceHandler.h> |
|
33 #include <AiwPoCParameters.h> |
|
34 #include <coemain.h> |
|
35 |
|
36 // Debugging headers |
|
37 #include <Pbk2Debug.h> |
|
38 |
|
39 |
|
40 // -------------------------------------------------------------------------- |
|
41 // CPbk2PocCmd::CPbk2PocCmd |
|
42 // -------------------------------------------------------------------------- |
|
43 // |
|
44 CPbk2PocCmd::CPbk2PocCmd( const TInt aCommandId, |
|
45 CAiwServiceHandler& aServiceHandler, |
|
46 CPbk2CallTypeSelector& aSelector, |
|
47 MPbk2ContactUiControl& aControl, |
|
48 const MVPbkStoreContact& aContact, |
|
49 MVPbkStoreContactField* aSelectedField ) : |
|
50 iCommandId( aCommandId ), |
|
51 iServiceHandler( aServiceHandler ), |
|
52 iSelector( aSelector ), |
|
53 iControl( &aControl ), |
|
54 iContact( aContact ), |
|
55 iSelectedField( aSelectedField ) |
|
56 { |
|
57 PBK2_DEBUG_PRINT |
|
58 (PBK2_DEBUG_STRING("CPbk2PocCmd::CPbk2PocCmd(0x%x)"), this); |
|
59 } |
|
60 |
|
61 // -------------------------------------------------------------------------- |
|
62 // CPbk2PocCmd::~CPbk2PocCmd |
|
63 // -------------------------------------------------------------------------- |
|
64 // |
|
65 CPbk2PocCmd::~CPbk2PocCmd() |
|
66 { |
|
67 PBK2_DEBUG_PRINT |
|
68 (PBK2_DEBUG_STRING("CPbk2PocCmd::~CPbk2PocCmd(0x%x)"), this); |
|
69 delete iSelectedField; |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CPbk2PocCmd::NewL |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 CPbk2PocCmd* CPbk2PocCmd::NewL( |
|
77 const TInt aCommandId, CAiwServiceHandler& aServiceHandler, |
|
78 CPbk2CallTypeSelector& aSelector, |
|
79 MPbk2ContactUiControl& aControl, |
|
80 const MVPbkStoreContact& aContact, |
|
81 MVPbkStoreContactField* aSelectedField ) |
|
82 { |
|
83 CPbk2PocCmd* self = new ( ELeave ) CPbk2PocCmd( aCommandId, |
|
84 aServiceHandler, aSelector, aControl, aContact, |
|
85 aSelectedField ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 // -------------------------------------------------------------------------- |
|
90 // CPbk2PocCmd::ExecuteLD |
|
91 // -------------------------------------------------------------------------- |
|
92 // |
|
93 void CPbk2PocCmd::ExecuteLD() |
|
94 { |
|
95 PBK2_DEBUG_PRINT |
|
96 (PBK2_DEBUG_STRING("CPbk2PocCmd::ExecuteLD(0x%x)"), this); |
|
97 |
|
98 CleanupStack::PushL( this ); |
|
99 |
|
100 if (iControl) |
|
101 { |
|
102 CAiwGenericParamList& inParamList = iServiceHandler.InParamListL(); |
|
103 TAiwPocParameterData pocParameter; |
|
104 pocParameter.iConsumerAppUid = TUid::Uid( KPbk2UID3 ); |
|
105 pocParameter.iConsumerWindowGroup = |
|
106 CCoeEnv::Static()->RootWin().Identifier(); |
|
107 pocParameter.iCommandId = 0; |
|
108 |
|
109 // Select PoC call type |
|
110 if ( iCommandId == EPbk2CmdPoC || iCommandId == EPbk2CmdCall ) |
|
111 { |
|
112 // We must select one call type when using PoC key |
|
113 pocParameter.iCommandId = |
|
114 iSelector.SelectPocCallTypeForPocKeyPress( *iControl ); |
|
115 } |
|
116 else |
|
117 { |
|
118 // Use call type selector to deduct what call type to use |
|
119 pocParameter.iPreferredMenu = |
|
120 iSelector.SelectPocCallType( *iControl ); |
|
121 } |
|
122 |
|
123 // Append PoC parameter data to parameter list |
|
124 TAiwGenericParam param = TAiwGenericParam( |
|
125 EGenericParamPoCData, |
|
126 TAiwVariant( TAiwPocParameterDataPckg( pocParameter ) ) ); |
|
127 inParamList.AppendL( param ); |
|
128 |
|
129 // Append contact links to parameter list |
|
130 MVPbkContactLinkArray* linkArray = NULL; |
|
131 if ( iSelectedField ) |
|
132 { |
|
133 CVPbkContactLinkArray* array = CVPbkContactLinkArray::NewLC(); |
|
134 |
|
135 // If selected field is set create field link from it |
|
136 MVPbkContactLink* contactLink = iSelectedField->CreateLinkLC(); |
|
137 CleanupStack::Pop(); // contactLink |
|
138 array->AppendL( contactLink ); |
|
139 linkArray = array; |
|
140 } |
|
141 else |
|
142 { |
|
143 linkArray = iControl->SelectedContactsOrFocusedContactL(); |
|
144 CleanupDeletePushL( linkArray ); |
|
145 } |
|
146 |
|
147 if ( linkArray ) |
|
148 { |
|
149 HBufC8* packedLinks = linkArray->PackLC(); |
|
150 inParamList.AppendL( TAiwGenericParam( |
|
151 EGenericParamContactLinkArray, TAiwVariant( *packedLinks ) ) ); |
|
152 CleanupStack::PopAndDestroy(); // packedLinks |
|
153 } |
|
154 |
|
155 CleanupStack::PopAndDestroy(); // linkArray |
|
156 |
|
157 // If the command id is EPbk2CmdPoC it means the call was launched |
|
158 // with PoC key and we therefore must use different AIW command |
|
159 // than when the call was selected from the menu. The same applies |
|
160 // when the call is made with Send key (EPbk2CmdCall). |
|
161 if ( iCommandId == EPbk2CmdPoC || iCommandId == EPbk2CmdCall) |
|
162 { |
|
163 iServiceHandler.ExecuteServiceCmdL( |
|
164 KAiwCmdPoC, |
|
165 inParamList, |
|
166 iServiceHandler.OutParamListL(), |
|
167 0, // no options used. |
|
168 NULL); // no need for callback |
|
169 } |
|
170 else // the call was launched from menu |
|
171 { |
|
172 // Relay the command to AIW for handling |
|
173 iServiceHandler.ExecuteMenuCmdL( |
|
174 iCommandId, |
|
175 inParamList, |
|
176 iServiceHandler.OutParamListL(), |
|
177 0, // no options used. |
|
178 NULL); // no need for callback |
|
179 } |
|
180 |
|
181 // Update UI control |
|
182 TInt fieldIndex = iControl->FocusedFieldIndex(); |
|
183 iControl->ClearMarks(); |
|
184 iControl->ResetFindL(); |
|
185 iControl->SetFocusedContactL( iContact ); |
|
186 iControl->SetFocusedFieldIndex( fieldIndex ); |
|
187 } |
|
188 |
|
189 // Destroy itself as promised |
|
190 CleanupStack::PopAndDestroy(); // this |
|
191 } |
|
192 |
|
193 // -------------------------------------------------------------------------- |
|
194 // CPbk2PocCmd::ResetUiControl |
|
195 // -------------------------------------------------------------------------- |
|
196 // |
|
197 void CPbk2PocCmd::ResetUiControl( |
|
198 MPbk2ContactUiControl& aUiControl) |
|
199 { |
|
200 if (iControl == &aUiControl) |
|
201 { |
|
202 iControl = NULL; |
|
203 } |
|
204 } |
|
205 |
|
206 // -------------------------------------------------------------------------- |
|
207 // CPbk2PocCmd::AddObserver |
|
208 // -------------------------------------------------------------------------- |
|
209 // |
|
210 void CPbk2PocCmd::AddObserver( MPbk2CommandObserver& /*aObserver*/ ) |
|
211 { |
|
212 // Do nothing |
|
213 } |
|
214 |
|
215 // End of File |