19
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "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 |
* Kanrikogaku Kenkyusho, Ltd. - Initial contribution
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <aknviewappui.h>
|
|
19 |
#include <akntoolbar.h>
|
|
20 |
#include <barsread.h>
|
|
21 |
#include <DirectPrintApp.rsg>
|
|
22 |
#include <stringloader.h> // StringLoader
|
|
23 |
|
|
24 |
#include "clog.h"
|
|
25 |
#include "directprintapp.hrh"
|
|
26 |
#include "directprintsearchresultview.h"
|
|
27 |
|
|
28 |
CDirectPrintSearchResultView::CDirectPrintSearchResultView()
|
|
29 |
{
|
|
30 |
iListBox = NULL;
|
|
31 |
}
|
|
32 |
|
|
33 |
CDirectPrintSearchResultView::~CDirectPrintSearchResultView()
|
|
34 |
{
|
|
35 |
AppUi()->RemoveFromViewStack(*this, iListBox);
|
|
36 |
|
|
37 |
if (iPeriodic)
|
|
38 |
{
|
|
39 |
iPeriodic->Cancel();
|
|
40 |
delete iPeriodic;
|
|
41 |
iPeriodic = NULL;
|
|
42 |
}
|
|
43 |
|
|
44 |
if (iProgressDialog)
|
|
45 |
{
|
|
46 |
TRAP_IGNORE(iProgressDialog->ProcessFinishedL());
|
|
47 |
delete iProgressDialog;
|
|
48 |
iProgressDialog = NULL;
|
|
49 |
}
|
|
50 |
if (iProgressMessage)
|
|
51 |
{
|
|
52 |
delete iProgressMessage;
|
|
53 |
iProgressMessage = NULL;
|
|
54 |
}
|
|
55 |
|
|
56 |
delete iListBox;
|
|
57 |
delete iItemArray;
|
|
58 |
}
|
|
59 |
|
|
60 |
CDirectPrintSearchResultView* CDirectPrintSearchResultView::NewL()
|
|
61 |
{
|
|
62 |
CDirectPrintSearchResultView* self = CDirectPrintSearchResultView::NewLC();
|
|
63 |
CleanupStack::Pop(self);
|
|
64 |
return self;
|
|
65 |
}
|
|
66 |
|
|
67 |
CDirectPrintSearchResultView* CDirectPrintSearchResultView::NewLC()
|
|
68 |
{
|
|
69 |
CDirectPrintSearchResultView* self = new(ELeave) CDirectPrintSearchResultView();
|
|
70 |
CleanupStack::PushL(self);
|
|
71 |
self->ConstructL();
|
|
72 |
return self;
|
|
73 |
}
|
|
74 |
|
|
75 |
void CDirectPrintSearchResultView::ConstructL()
|
|
76 |
{
|
|
77 |
LOG("CDirectPrintSearchResultView::ConstructL BEGIN");
|
|
78 |
BaseConstructL(R_DIRECTPRINT_SEARCHRESULT_VIEW);
|
|
79 |
|
|
80 |
iViewId = TUid::Uid(EDirectPrintSearchResultViewId);
|
|
81 |
|
|
82 |
iItemArray = new(ELeave) CDesCArrayFlat(3);
|
|
83 |
LOG("CDirectPrintSearchResultView::ConstructL END");
|
|
84 |
}
|
|
85 |
|
|
86 |
void CDirectPrintSearchResultView::HandleCommandL(TInt aCommand)
|
|
87 |
{
|
|
88 |
switch (aCommand)
|
|
89 |
{
|
|
90 |
case EAknSoftkeyCancel:
|
|
91 |
{
|
|
92 |
AppUi()->HandleCommandL(EDirectPrintCmdIdSearchResultViewCancel);
|
|
93 |
}
|
|
94 |
break;
|
|
95 |
case EDirectPrintCmdIdSearchResultViewSearch:
|
|
96 |
{
|
|
97 |
AppUi()->HandleCommandL(aCommand);
|
|
98 |
}
|
|
99 |
break;
|
|
100 |
default:
|
|
101 |
{
|
|
102 |
AppUi()->HandleCommandL(aCommand);
|
|
103 |
}
|
|
104 |
break;
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
void CDirectPrintSearchResultView::HandleListIndexL(TInt /*aIndex*/)
|
|
109 |
{
|
|
110 |
AppUi()->HandleCommandL(EDirectPrintCmdIdSearchResultViewSelect);
|
|
111 |
}
|
|
112 |
|
|
113 |
void CDirectPrintSearchResultView::OfferToolbarEventL(TInt aCommand)
|
|
114 |
{
|
|
115 |
switch (aCommand)
|
|
116 |
{
|
|
117 |
case EDirectPrintCmdIdPrinterListViewEdit:
|
|
118 |
{
|
|
119 |
AppUi()->HandleCommandL(aCommand);
|
|
120 |
}
|
|
121 |
break;
|
|
122 |
default:
|
|
123 |
break;
|
|
124 |
}
|
|
125 |
}
|
|
126 |
|
|
127 |
void CDirectPrintSearchResultView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
|
|
128 |
{
|
|
129 |
LOG("CDirectPrintSearchResultView::DoActivateL BEGIN");
|
|
130 |
CAknToolbar* toolbar = AppUi()->CurrentFixedToolbar();
|
|
131 |
toolbar->SetToolbarObserver(this);
|
|
132 |
|
|
133 |
// Create list box
|
|
134 |
if (!iListBox)
|
|
135 |
{
|
|
136 |
iListBox = CDirectPrintListBox::NewL(ClientRect(), iItemArray);
|
|
137 |
iListBox->SetMopParent(this);
|
|
138 |
iListBox->SetListObserver(this);
|
|
139 |
}
|
|
140 |
AppUi()->AddToStackL(*this, iListBox);
|
|
141 |
iListBox->MakeVisible(ETrue);
|
|
142 |
|
|
143 |
// set the title pane
|
|
144 |
SetActiveTitleL(R_DIRECTPRINT_PRINTERSEARCH_TITLE);
|
|
145 |
|
|
146 |
StartSearchL();
|
|
147 |
LOG("CDirectPrintSearchResultView::DoActivateL END");
|
|
148 |
}
|
|
149 |
|
|
150 |
void CDirectPrintSearchResultView::DoDeactivate()
|
|
151 |
{
|
|
152 |
LOG("CDirectPrintSearchResultView::DoDeactivate BEGIN");
|
|
153 |
iListBox->MakeVisible(EFalse);
|
|
154 |
AppUi()->RemoveFromViewStack(*this, iListBox);
|
|
155 |
LOG("CDirectPrintSearchResultView::DoDeactivate END");
|
|
156 |
}
|
|
157 |
|
|
158 |
void CDirectPrintSearchResultView::StartSearchProgressNoteL()
|
|
159 |
{
|
|
160 |
// Delete possible previous CAknProgressDialog.
|
|
161 |
if (iProgressDialog)
|
|
162 |
{
|
|
163 |
delete iProgressDialog;
|
|
164 |
iProgressDialog = NULL;
|
|
165 |
}
|
|
166 |
|
|
167 |
if (!iProgressMessage)
|
|
168 |
{
|
|
169 |
// read progress message
|
|
170 |
iProgressMessage = StringLoader::LoadL( R_DIRECTPRINT_MSG_SEARCHING_PROGRESS );
|
|
171 |
}
|
|
172 |
|
|
173 |
// Create new CAknProgressDialog.
|
|
174 |
iProgressDialog = new ( ELeave ) CAknProgressDialog( reinterpret_cast
|
|
175 |
<CEikDialog**>
|
|
176 |
( &iProgressDialog ) );
|
|
177 |
iProgressDialog->SetCallback( this );
|
|
178 |
iProgressDialog->PrepareLC( R_DIRECTPRINT_SEARCH_PROGRESS_NOTE );
|
|
179 |
//iProgressInfo = iProgressDialog->GetProgressInfoL();
|
|
180 |
//iProgressInfo->SetFinalValue( 1 );
|
|
181 |
|
|
182 |
iProgressDialog->SetTextL(*iProgressMessage);
|
|
183 |
iProgressDialog->RunLD();
|
|
184 |
}
|
|
185 |
|
|
186 |
void CDirectPrintSearchResultView::EndProgressNoteL()
|
|
187 |
{
|
|
188 |
if (iProgressDialog)
|
|
189 |
{
|
|
190 |
iProgressDialog->ProcessFinishedL();
|
|
191 |
if (iProgressDialog)
|
|
192 |
{
|
|
193 |
delete iProgressDialog;
|
|
194 |
iProgressDialog = NULL;
|
|
195 |
}
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
void CDirectPrintSearchResultView::StartSearchL()
|
|
200 |
{
|
|
201 |
const TInt KSearchTimeoutTime(10000000); // 10 sec
|
|
202 |
|
|
203 |
if (iPeriodic)
|
|
204 |
{
|
|
205 |
iPeriodic->Cancel();
|
|
206 |
}
|
|
207 |
else
|
|
208 |
{
|
|
209 |
iPeriodic = CPeriodic::NewL(CActive::EPriorityIdle);
|
|
210 |
}
|
|
211 |
iPeriodic->Start(KSearchTimeoutTime, KSearchTimeoutTime, TCallBack(HandleTimeout, this));
|
|
212 |
StartSearchProgressNoteL();
|
|
213 |
}
|
|
214 |
|
|
215 |
TInt CDirectPrintSearchResultView::HandleTimeout(TAny* aAny)
|
|
216 |
{
|
|
217 |
// Setting size button back to up state
|
|
218 |
|
|
219 |
CDirectPrintSearchResultView* self = static_cast<CDirectPrintSearchResultView*>( aAny );
|
|
220 |
// Cancel timer
|
|
221 |
TRAPD( err, self->HandleTimeoutL());
|
|
222 |
return err;
|
|
223 |
}
|
|
224 |
|
|
225 |
void CDirectPrintSearchResultView::HandleTimeoutL()
|
|
226 |
{
|
|
227 |
iTimeoutCount++;
|
|
228 |
if (iTimeoutCount == 1)
|
|
229 |
{
|
|
230 |
// for test
|
|
231 |
TBuf<50> buf;
|
|
232 |
buf.Copy(_L("\tCanon MP640_000XXX\t"));
|
|
233 |
iItemArray->AppendL(buf);
|
|
234 |
iListBox->DrawNow();
|
|
235 |
}
|
|
236 |
else if (iTimeoutCount > 1)
|
|
237 |
{
|
|
238 |
EndProgressNoteL();
|
|
239 |
if (iPeriodic)
|
|
240 |
{
|
|
241 |
iPeriodic->Cancel();
|
|
242 |
delete iPeriodic;
|
|
243 |
iPeriodic = NULL;
|
|
244 |
}
|
|
245 |
iTimeoutCount = 0;
|
|
246 |
}
|
|
247 |
}
|
|
248 |
|
|
249 |
void CDirectPrintSearchResultView::DialogDismissedL( TInt aButtonId )
|
|
250 |
{
|
|
251 |
//TInt button = aButtonId;
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
// End of file
|