|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * Remote contact lookup command event handling class. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbkRclCmd.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include <Pbk2Commands.rsg> |
|
24 #include <MPbk2CommandObserver.h> |
|
25 #include <MPbk2ContactUiControl.h> |
|
26 |
|
27 //#include <CVPbkContactStoreUriArray.h> |
|
28 |
|
29 // RCL |
|
30 #include <pbk2remotecontactlookupfactory.h> |
|
31 #include <cpbk2remotecontactlookupaccounts.h> |
|
32 #include <cpbkxremotecontactlookupserviceuicontext.h> |
|
33 |
|
34 // System includes |
|
35 #include <StringLoader.h> |
|
36 #include <avkon.hrh> |
|
37 |
|
38 /// Unnamed namespace for local definitions |
|
39 namespace { |
|
40 |
|
41 enum TPbk2RclCmdState |
|
42 { |
|
43 ELaunchDialog, |
|
44 EComplete |
|
45 }; |
|
46 |
|
47 } /// namespace |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // CPbkRclCmd::CPbkRclCmd |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 CPbkRclCmd::CPbkRclCmd |
|
54 ( MPbk2ContactUiControl& aUiControl ) : |
|
55 CActive( EPriorityStandard ), |
|
56 iUiControl(aUiControl) |
|
57 { |
|
58 } |
|
59 |
|
60 // -------------------------------------------------------------------------- |
|
61 // CPbkRclCmd::~CPbkRclCmd |
|
62 // -------------------------------------------------------------------------- |
|
63 // |
|
64 CPbkRclCmd::~CPbkRclCmd() |
|
65 { |
|
66 Cancel(); |
|
67 } |
|
68 |
|
69 // -------------------------------------------------------------------------- |
|
70 // CPbkRclCmd::NewL |
|
71 // -------------------------------------------------------------------------- |
|
72 // |
|
73 CPbkRclCmd* CPbkRclCmd::NewL( |
|
74 MPbk2ContactUiControl& aUiControl) |
|
75 { |
|
76 CPbkRclCmd* self = |
|
77 new( ELeave ) CPbkRclCmd(aUiControl); |
|
78 CleanupStack::PushL( self ); |
|
79 self->ConstructL(); |
|
80 CleanupStack::Pop( self ); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // -------------------------------------------------------------------------- |
|
85 // CPbkRclCmd::ConstructL |
|
86 // -------------------------------------------------------------------------- |
|
87 // |
|
88 void CPbkRclCmd::ConstructL() |
|
89 { |
|
90 CActiveScheduler::Add(this); |
|
91 } |
|
92 |
|
93 // -------------------------------------------------------------------------- |
|
94 // CPbkRclCmd::ExecuteLD |
|
95 // -------------------------------------------------------------------------- |
|
96 // |
|
97 void CPbkRclCmd::ExecuteLD() |
|
98 { |
|
99 iState = ELaunchDialog; |
|
100 IssueRequest(); |
|
101 } |
|
102 |
|
103 // -------------------------------------------------------------------------- |
|
104 // CPbkRclCmd::AddObserver |
|
105 // -------------------------------------------------------------------------- |
|
106 // |
|
107 void CPbkRclCmd::AddObserver(MPbk2CommandObserver& aObserver) |
|
108 { |
|
109 iCommandObserver = &aObserver; |
|
110 } |
|
111 |
|
112 // -------------------------------------------------------------------------- |
|
113 // CPbkRclCmd::ResetUiControl |
|
114 // -------------------------------------------------------------------------- |
|
115 // |
|
116 void CPbkRclCmd::ResetUiControl( |
|
117 MPbk2ContactUiControl& /*aUiControl*/) |
|
118 { |
|
119 // Do nothing |
|
120 } |
|
121 |
|
122 // -------------------------------------------------------------------------- |
|
123 // CPbkRclCmd::RunL |
|
124 // -------------------------------------------------------------------------- |
|
125 // |
|
126 void CPbkRclCmd::RunL() |
|
127 { |
|
128 switch (iState) |
|
129 { |
|
130 case ELaunchDialog: |
|
131 { |
|
132 LaunchDialogL(); |
|
133 break; |
|
134 } |
|
135 case EComplete: // FALLTHROUGH |
|
136 default: |
|
137 { |
|
138 iCommandObserver->CommandFinished(*this); |
|
139 break; |
|
140 } |
|
141 } |
|
142 } |
|
143 |
|
144 // -------------------------------------------------------------------------- |
|
145 // CPbkRclCmd::DoCancel |
|
146 // -------------------------------------------------------------------------- |
|
147 // |
|
148 void CPbkRclCmd::DoCancel() |
|
149 { |
|
150 } |
|
151 |
|
152 // -------------------------------------------------------------------------- |
|
153 // CPbkRclCmd::RunError |
|
154 // -------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CPbkRclCmd::RunError(TInt aError) |
|
157 { |
|
158 HandleError(aError); |
|
159 return KErrNone; |
|
160 } |
|
161 |
|
162 // -------------------------------------------------------------------------- |
|
163 // CPbkRclCmd::IssueRequest |
|
164 // -------------------------------------------------------------------------- |
|
165 // |
|
166 void CPbkRclCmd::IssueRequest() |
|
167 { |
|
168 TRequestStatus* status = &iStatus; |
|
169 User::RequestComplete(status, KErrNone); |
|
170 SetActive(); |
|
171 } |
|
172 |
|
173 // -------------------------------------------------------------------------- |
|
174 // CPbkRclCmd::LaunchDialogL |
|
175 // -------------------------------------------------------------------------- |
|
176 // |
|
177 void CPbkRclCmd::LaunchDialogL() |
|
178 { |
|
179 TPbkxRemoteContactLookupProtocolAccountId account = CPbk2RemoteContactLookupAccounts::DefaultAccountIdL(); |
|
180 |
|
181 CPbkxRemoteContactLookupServiceUiContext::TContextParams params = { account, |
|
182 CPbkxRemoteContactLookupServiceUiContext::EModeNormal }; |
|
183 |
|
184 CPbkxRemoteContactLookupServiceUiContext* ctx = |
|
185 Pbk2RemoteContactLookupFactory::NewContextL( params ); |
|
186 CleanupStack::PushL( ctx ); |
|
187 |
|
188 CPbkxRemoteContactLookupServiceUiContext::TResult aResult; |
|
189 |
|
190 // If user hasn't entered any characters to the findbox - FindTextL |
|
191 // returns an empty string and the search query is left blank. |
|
192 ctx->ExecuteL( iUiControl.FindTextL(), aResult ); |
|
193 |
|
194 CleanupStack::PopAndDestroy( ctx ); |
|
195 |
|
196 iState = EComplete; |
|
197 IssueRequest(); |
|
198 } |
|
199 |
|
200 // -------------------------------------------------------------------------- |
|
201 // CPbkRclCmd::HandleError |
|
202 // -------------------------------------------------------------------------- |
|
203 // |
|
204 void CPbkRclCmd::HandleError(TInt aError) |
|
205 { |
|
206 if (aError != KErrNone) |
|
207 { |
|
208 iCommandObserver->CommandFinished(*this); |
|
209 CCoeEnv::Static()->HandleError(aError); |
|
210 } |
|
211 } |
|
212 |
|
213 // End of File |