|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of CPhoneTextQuery class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cphonetextquery.h" |
|
21 #include "phoneui.hrh" |
|
22 #include "phonelogger.h" |
|
23 #include "phoneconstants.h" |
|
24 |
|
25 // ================= MEMBER FUNCTIONS ======================= |
|
26 // C++ default constructor can NOT contain any code, that |
|
27 // might leave. |
|
28 // |
|
29 CPhoneTextQuery::CPhoneTextQuery( |
|
30 MEikCommandObserver& aCommandObserver, |
|
31 TDes& aDataText, |
|
32 TInt aDefaultCbaResourceId, |
|
33 TInt aContentCbaResourceId, |
|
34 TBool aSendKeyEnabled, |
|
35 TInt aEikBidOkCmd ) : |
|
36 CAknTextQueryDialog( aDataText, CAknQueryDialog::ENoTone ), |
|
37 iCommandObserver( aCommandObserver ), |
|
38 iDefaultCbaResourceId( aDefaultCbaResourceId ), |
|
39 iContentCbaResourceId( aContentCbaResourceId ), |
|
40 iSendKeyHandlingEnabled( aSendKeyEnabled ), |
|
41 iEikBidOkCmd( aEikBidOkCmd ) |
|
42 { |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // Destructor |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 CPhoneTextQuery::~CPhoneTextQuery() |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CPhoneTextQuery::OfferKeyEventL |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 TKeyResponse CPhoneTextQuery::OfferKeyEventL( |
|
58 const TKeyEvent& aKeyEvent, |
|
59 TEventCode aType ) |
|
60 { |
|
61 TKeyResponse response ( EKeyWasConsumed ); |
|
62 // Send or Ok key down event |
|
63 if ( aKeyEvent.iScanCode == EStdKeyYes && aType == EEventKeyDown ) |
|
64 { |
|
65 // Send key enabled |
|
66 if ( iSendKeyHandlingEnabled ) |
|
67 { |
|
68 OkToExitL( EPhoneInCallCmdNewCallCall ); |
|
69 } |
|
70 } |
|
71 else if ( aType == EEventKey && |
|
72 ( aKeyEvent.iScanCode == EStdKeyNo || aKeyEvent.iCode == EKeyNo ) ) |
|
73 { |
|
74 OkToExitL( EPhoneCmdEnd ); |
|
75 } |
|
76 else if ( aKeyEvent.iCode == EKeyEnter && aType == EEventKey ) |
|
77 { |
|
78 TInt commandID = FetchCommandFromCba(); |
|
79 if ( commandID ) |
|
80 { |
|
81 TryExitL( commandID ); |
|
82 } |
|
83 } |
|
84 else |
|
85 { |
|
86 UpdateSoftkeysL(); |
|
87 response = CAknTextQueryDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
88 } |
|
89 return response; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CPhoneTextQuery::OkToExitL |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 TBool CPhoneTextQuery::OkToExitL( TInt aCommand ) |
|
97 { |
|
98 // Let the command observer process the command |
|
99 if ( aCommand == EEikBidOk ) |
|
100 { |
|
101 iCommandObserver.ProcessCommandL( iEikBidOkCmd ); |
|
102 } |
|
103 else |
|
104 { |
|
105 iCommandObserver.ProcessCommandL( aCommand ); |
|
106 } |
|
107 |
|
108 return ETrue; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CPhoneTextQuery::PostLayoutDynInitL |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 void CPhoneTextQuery::PostLayoutDynInitL() |
|
116 { |
|
117 CAknQueryControl* control = |
|
118 static_cast< CAknQueryControl* >( Control( EGeneralQuery ) ); |
|
119 |
|
120 control->SetTextEntryLength( KPhoneNumberEntryBufferSize ); |
|
121 CAknTextQueryDialog::PostLayoutDynInitL(); |
|
122 UpdateSoftkeysL(); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------- |
|
126 // CPhoneTextQuery::UpdateSoftkeysL |
|
127 // --------------------------------------------------------- |
|
128 // |
|
129 void CPhoneTextQuery::UpdateSoftkeysL() |
|
130 { |
|
131 CAknQueryControl* control = |
|
132 static_cast< CAknQueryControl* >( Control( EGeneralQuery ) ); |
|
133 |
|
134 CEikButtonGroupContainer& buttonGroup = ButtonGroupContainer(); |
|
135 |
|
136 if ( control->GetTextLength() ) |
|
137 { |
|
138 // There is text in cba; we can update softkeys to ok - cancel |
|
139 buttonGroup.SetCommandSetL( iContentCbaResourceId ); |
|
140 MakeLeftSoftkeyVisible( ETrue ); |
|
141 } |
|
142 else |
|
143 { |
|
144 // There is no text in cba; update softkeys to find - cancel |
|
145 buttonGroup.SetCommandSetL( iDefaultCbaResourceId ); |
|
146 MakeLeftSoftkeyVisible( ETrue ); |
|
147 } |
|
148 |
|
149 buttonGroup.DrawDeferred(); |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------- |
|
153 // CPhoneTextQuery::GetContent |
|
154 // --------------------------------------------------------- |
|
155 // |
|
156 void CPhoneTextQuery::GetContent( TDes& aText ) |
|
157 { |
|
158 CAknQueryControl* control = |
|
159 static_cast< CAknQueryControl* >( Control( EGeneralQuery ) ); |
|
160 |
|
161 control->GetText( aText ); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // CPhoneTextQuery::FetchCommandFromCba |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 TInt CPhoneTextQuery::FetchCommandFromCba() |
|
169 { |
|
170 TInt commandID = 0; |
|
171 CEikCba* cba = NULL; |
|
172 cba = MopGetObject( cba ); |
|
173 |
|
174 if ( cba ) |
|
175 { |
|
176 commandID = cba->CommandId( 0 ); |
|
177 } |
|
178 |
|
179 return commandID; |
|
180 } |
|
181 |
|
182 // End of File |