|
1 /* |
|
2 * Copyright (c) 2002 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 * Provides phonebook call command object methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkCallCmd.h" |
|
22 |
|
23 #include <CPbkContactItem.h> |
|
24 #include <TPbkContactItemField.h> |
|
25 #include <CPbkFieldInfo.h> |
|
26 #include <Phonebook.hrh> |
|
27 #include "CPbkCallTypeSelector.h" |
|
28 #include <pbkdebug.h> |
|
29 |
|
30 #include <coemain.h> |
|
31 #include <AiwServiceHandler.h> // AIW |
|
32 #include <AiwCommon.hrh> // AIW |
|
33 |
|
34 |
|
35 |
|
36 /// Unnamed namespace for local definitions |
|
37 namespace { |
|
38 |
|
39 // LOCAL DEBUG CODE |
|
40 #ifdef _DEBUG |
|
41 enum TPanicCode |
|
42 { |
|
43 EPanicPreCond_SetupDialData = 1 |
|
44 }; |
|
45 |
|
46 void Panic(TPanicCode aReason) |
|
47 { |
|
48 _LIT(KPanicText, "CPbkCallCmd"); |
|
49 User::Panic(KPanicText,aReason); |
|
50 } |
|
51 #endif |
|
52 |
|
53 } // namespace |
|
54 |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 |
|
58 // Default constructor |
|
59 CPbkCallCmd::CPbkCallCmd( |
|
60 const CPbkContactItem& aContactItem, |
|
61 const TPbkContactItemField* aSelectedField, |
|
62 const TPbkContactItemField* aFocusedField, |
|
63 const TInt aCommandId, |
|
64 CAiwServiceHandler& aServiceHandler, |
|
65 const CPbkCallTypeSelector& aSelector) : |
|
66 iContact(aContactItem), |
|
67 iSelectedField(aSelectedField), |
|
68 iFocusedField(aFocusedField), |
|
69 iCommandId(aCommandId), |
|
70 iServiceHandler(aServiceHandler), |
|
71 iSelector(aSelector) |
|
72 { |
|
73 PBK_DEBUG_PRINT |
|
74 (PBK_DEBUG_STRING("CPbkCallCmd::CPbkCallCmd(0x%x)"), this); |
|
75 } |
|
76 |
|
77 // Static constructor |
|
78 CPbkCallCmd* CPbkCallCmd::NewL( |
|
79 const CPbkContactItem& aContactItem, |
|
80 const TPbkContactItemField* aSelectedField, |
|
81 const TPbkContactItemField* aFocusedField, |
|
82 const TInt aCommandId, |
|
83 CAiwServiceHandler& aServiceHandler, |
|
84 const CPbkCallTypeSelector& aSelector) |
|
85 { |
|
86 CPbkCallCmd* self = new(ELeave) CPbkCallCmd( |
|
87 aContactItem, |
|
88 aSelectedField, |
|
89 aFocusedField, |
|
90 aCommandId, |
|
91 aServiceHandler, |
|
92 aSelector); |
|
93 return self; |
|
94 } |
|
95 |
|
96 // Destructor |
|
97 CPbkCallCmd::~CPbkCallCmd() |
|
98 { |
|
99 PBK_DEBUG_PRINT |
|
100 (PBK_DEBUG_STRING("CPbkCallCmd::~CPbkCallCmd(0x%x)"), this); |
|
101 } |
|
102 |
|
103 void CPbkCallCmd::ExecuteLD() |
|
104 { |
|
105 PBK_DEBUG_PRINT |
|
106 (PBK_DEBUG_STRING("CPbkCallCmd::ExecuteLD(0x%x)"), this); |
|
107 |
|
108 CleanupStack::PushL(this); |
|
109 |
|
110 // First setup dial data |
|
111 SetupDialDataL(); |
|
112 TAiwDialDataV1Pckg dialDataPckg(iDialData); |
|
113 |
|
114 // Set parameters for the AIW call |
|
115 CAiwGenericParamList& paramList = iServiceHandler.InParamListL(); |
|
116 TPtrC8 ptr; |
|
117 ptr.Set(dialDataPckg); |
|
118 TAiwVariant variant(ptr); |
|
119 |
|
120 TAiwGenericParam param(EGenericParamCallDialDataV1, variant); |
|
121 paramList.AppendL(param); |
|
122 |
|
123 // If the command id is EPbkCmdCall it means the call was launched |
|
124 // with send key and we therefore must use different AIW command |
|
125 // than when the call was selected from the menu |
|
126 if (iCommandId == EPbkCmdCall) |
|
127 { |
|
128 iServiceHandler.ExecuteServiceCmdL( |
|
129 KAiwCmdCall, |
|
130 paramList, |
|
131 iServiceHandler.OutParamListL(), |
|
132 0, |
|
133 NULL ); |
|
134 } |
|
135 else // the call was launched from menu |
|
136 { |
|
137 // Relay the command to AIW for handling |
|
138 iServiceHandler.ExecuteMenuCmdL( |
|
139 iCommandId, |
|
140 paramList, |
|
141 iServiceHandler.OutParamListL(), |
|
142 0, // No options used. |
|
143 NULL); // No need for callback |
|
144 } |
|
145 |
|
146 // Destroy itself as promised |
|
147 CleanupStack::PopAndDestroy(); // this |
|
148 } |
|
149 |
|
150 /** |
|
151 * Sets up aDialData for a call to aContact's aField. |
|
152 */ |
|
153 inline void CPbkCallCmd::SetupDialDataL() |
|
154 { |
|
155 // Set basic dial data |
|
156 iDialData.SetWindowGroup(CCoeEnv::Static()->RootWin().Identifier()); |
|
157 iDialData.SetContactId(iContact.Id()); |
|
158 iDialData.SetRemoveInvalidChars(ETrue); |
|
159 if (iFocusedField) |
|
160 { |
|
161 iDialData.SetContactItemField(*iFocusedField); |
|
162 } |
|
163 |
|
164 if (iCommandId == EPbkCmdCall) |
|
165 { |
|
166 __ASSERT_DEBUG(iSelectedField, |
|
167 Panic(EPanicPreCond_SetupDialData)); |
|
168 |
|
169 // If the call is launched with send key, we have to fill certain |
|
170 // fields by ourselves |
|
171 iDialData.SetNumberType(iSelectedField->FieldInfo().FieldId()); |
|
172 TAiwTelephoneNumber phoneNumber(iSelectedField->Text(). |
|
173 Left(KAiwTelephoneNumberLength)); |
|
174 iDialData.SetTelephoneNumber(phoneNumber); |
|
175 |
|
176 // We also have select call type by ourselves |
|
177 iDialData.SetCallType(TAiwCallType( // the cast is safe |
|
178 iSelector.SelectCallType( |
|
179 iCommandId, |
|
180 iContact, |
|
181 iFocusedField, |
|
182 *iSelectedField))); |
|
183 } |
|
184 } |
|
185 |
|
186 void CPbkCallCmd::ProcessFinished(MPbkBackgroundProcess& /*aProcess*/) |
|
187 { |
|
188 PBK_DEBUG_PRINT |
|
189 (PBK_DEBUG_STRING("CPbkCallCmd::ProcessFinished(0x%x)"), this); |
|
190 } |
|
191 |
|
192 // End of File |