|
1 /* |
|
2 * Copyright (c) 2004-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 * |
|
16 */ |
|
17 |
|
18 |
|
19 // EXTERNAL INCLUDES |
|
20 #include <e32std.h> |
|
21 #include <barsc.h> |
|
22 #include <btprotocol.rsg> |
|
23 #include <fbs.h> |
|
24 |
|
25 #include "cbtprintingdevice.h" |
|
26 #include "printcapabilitycodes.h" |
|
27 #include "printmessagecodes.h" |
|
28 #include "rsutils.h" |
|
29 #include "crsbtdevice.h" |
|
30 #include "cbtdevicecontainer.h" |
|
31 #include "clog.h" |
|
32 #include "tbtmapper.h" |
|
33 #include "crsbtdiscoverengine.h" |
|
34 |
|
35 |
|
36 // CONSTANTS |
|
37 namespace |
|
38 { |
|
39 /// Bluetooth BPP/OPP Version Major. |
|
40 const static TInt KBtVersionMajor = 3; |
|
41 /// Bluetooth BPP/OPP Version Minor. |
|
42 const static TInt KBtVersionMinor = 0; |
|
43 /// Bluetooth BPP/OPP Version Build. |
|
44 const static TInt KBtVersionBuild = 1; |
|
45 } |
|
46 |
|
47 |
|
48 //-------------------------------------------------------------------------------------------- |
|
49 // |
|
50 // CBtPrintingDevice::NewL |
|
51 // |
|
52 //-------------------------------------------------------------------------------------------- |
|
53 MProtPrintingDevice* CBtPrintingDevice::NewL() |
|
54 { |
|
55 return new (ELeave) CBtPrintingDevice(); |
|
56 } |
|
57 |
|
58 |
|
59 //-------------------------------------------------------------------------------------------- |
|
60 // |
|
61 // CBtPrintingDevice::CBtPrintingDevice |
|
62 // |
|
63 //-------------------------------------------------------------------------------------------- |
|
64 CBtPrintingDevice::CBtPrintingDevice() : |
|
65 CActive(CActive::EPriorityStandard), |
|
66 iState( ENone ), |
|
67 iPrintingJob( NULL ), |
|
68 iPrinterController( NULL ), |
|
69 iDeviceContainer( NULL ), |
|
70 iRequestedProtocols( 0 ), |
|
71 iPrintError( KErrNone ), |
|
72 iPrintErrorMsgCode( 0 ), |
|
73 iPendingCount(KPendingLimit), |
|
74 iPrinterTimer( NULL ), |
|
75 iProggress( 0 ) |
|
76 { |
|
77 iDiscoveryObserver = NULL; |
|
78 iPrintEventObserver = NULL; |
|
79 CActiveScheduler::Add(this); |
|
80 } |
|
81 |
|
82 |
|
83 //-------------------------------------------------------------------------------------------- |
|
84 // |
|
85 // CBtPrintingDevice::ConstructL |
|
86 // |
|
87 //-------------------------------------------------------------------------------------------- |
|
88 void CBtPrintingDevice::ConstructL(const TDesC& /*aDLLPath*/) |
|
89 { |
|
90 LOG("CBtPrintingDevice ****************************************************"); |
|
91 LOG("[CBtPrintingDevice::ConstructL]\t begin"); |
|
92 |
|
93 iPrinterController = CBtPrinterController::NewL(*this); |
|
94 iDeviceContainer = CBtDeviceContainer::NewL(); |
|
95 iPrinterTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
96 LOG("CBtPrintingDevice::ConstructL end"); |
|
97 } |
|
98 |
|
99 //-------------------------------------------------------------------------------------------- |
|
100 // |
|
101 // CBtPrintingDevice::~CBtPrintingDevice |
|
102 // |
|
103 //-------------------------------------------------------------------------------------------- |
|
104 CBtPrintingDevice::~CBtPrintingDevice() |
|
105 { |
|
106 LOG("CBtPrintingDevice::~CBtPrintingDevice begin"); |
|
107 |
|
108 Deactivate(); |
|
109 |
|
110 if(iPrinterTimer) |
|
111 { |
|
112 if(iPrinterTimer->IsActive()) |
|
113 iPrinterTimer->Cancel(); |
|
114 delete iPrinterTimer; |
|
115 } |
|
116 |
|
117 if(iPrinterController) |
|
118 { |
|
119 iPrinterController->Stop(); |
|
120 delete iPrinterController; |
|
121 } |
|
122 |
|
123 if(iPrintingJob) |
|
124 delete iPrintingJob; |
|
125 |
|
126 if(iDeviceContainer) |
|
127 delete iDeviceContainer; |
|
128 |
|
129 REComSession::DestroyedImplementation( iDtor_ID_Key ); |
|
130 |
|
131 LOG("CBtPrintingDevice::~CBtPrintingDevice end"); |
|
132 } |
|
133 |
|
134 //-------------------------------------------------------------------------------------------- |
|
135 // |
|
136 // CBtPrintingDevice::RunL |
|
137 // |
|
138 //-------------------------------------------------------------------------------------------- |
|
139 void CBtPrintingDevice::RunL() |
|
140 { |
|
141 LOG1("[CBtPrintingDevice::RunL]\t iStatus: %d", iStatus.Int()); |
|
142 |
|
143 if(KErrNone != iStatus.Int()) |
|
144 { |
|
145 User::Leave(iStatus.Int()); |
|
146 } |
|
147 |
|
148 switch( iState ) |
|
149 { |
|
150 case EFinish: |
|
151 FinishPrinting(iStatus.Int()); |
|
152 break; |
|
153 case EGetJobAttributes: |
|
154 GetJobAttributesL(); |
|
155 break; |
|
156 case EGetPrinterState: |
|
157 GetPrinterStateL(); |
|
158 break; |
|
159 default: |
|
160 break; |
|
161 } |
|
162 } |
|
163 |
|
164 //-------------------------------------------------------------------------------------------- |
|
165 // |
|
166 // CBtPrintingDevice::RunError |
|
167 // |
|
168 //-------------------------------------------------------------------------------------------- |
|
169 TInt CBtPrintingDevice::RunError(TInt aError) |
|
170 { |
|
171 LOG2("[CBtPrintingDevice::RunError]\t iStatus: %d, aError: %d", iStatus.Int(), aError); |
|
172 |
|
173 FinishPrinting(aError); |
|
174 |
|
175 return KErrNone; |
|
176 } |
|
177 |
|
178 //-------------------------------------------------------------------------------------------- |
|
179 // |
|
180 // CBtPrintingDevice::DoCancel |
|
181 // |
|
182 //-------------------------------------------------------------------------------------------- |
|
183 void CBtPrintingDevice::DoCancel() |
|
184 { |
|
185 LOG1("[CBtPrintingDevice::DoCancel]\t iStatus: %d", iStatus.Int()); |
|
186 ResetTimer(); |
|
187 } |
|
188 |
|
189 //-------------------------------------------------------------------------------------------- |
|
190 // |
|
191 // CBtPrintingDevice::Deactivate |
|
192 // |
|
193 //-------------------------------------------------------------------------------------------- |
|
194 void CBtPrintingDevice::Deactivate() |
|
195 { |
|
196 LOG2("[CBtPrintingDevice::Deactivate]\t iStatus: %d iState %d", iStatus.Int(), iState); |
|
197 ResetTimer(); |
|
198 Cancel(); |
|
199 iStatus = KErrNone; |
|
200 } |
|
201 |
|
202 //-------------------------------------------------------------------------------------------- |
|
203 // |
|
204 // CBtPrintingDevice::Version |
|
205 // |
|
206 //-------------------------------------------------------------------------------------------- |
|
207 TVersion CBtPrintingDevice::Version() |
|
208 { |
|
209 return TVersion(KBtVersionMajor, KBtVersionMinor, KBtVersionBuild); |
|
210 } |
|
211 |
|
212 //-------------------------------------------------------------------------------------------- |
|
213 // |
|
214 // CBtPrintingDevice::SupportedProtocols |
|
215 // |
|
216 //-------------------------------------------------------------------------------------------- |
|
217 TUint CBtPrintingDevice::SupportedProtocols() |
|
218 { |
|
219 return KImagePrint_PrinterProtocol_BPP | |
|
220 KImagePrint_PrinterProtocol_OPP_Printer | |
|
221 KImagePrint_PrinterProtocol_OPP_PC; |
|
222 } |
|
223 |
|
224 |
|
225 //-------------------------------------------------------------------------------------------- |
|
226 // |
|
227 // CBtPrintingDevice::DiscoveryError |
|
228 // |
|
229 //-------------------------------------------------------------------------------------------- |
|
230 void CBtPrintingDevice::DiscoveryError(TInt aError) |
|
231 { |
|
232 LOG1("[CBtPrintingDevice::DiscoveryError]\t aError: %d", aError); |
|
233 if(0 < iDeviceContainer->Count()) |
|
234 { |
|
235 iState = EReady; |
|
236 } |
|
237 else |
|
238 { |
|
239 iState = ENone; |
|
240 } |
|
241 |
|
242 iPrinterController->CancelDiscovery(); |
|
243 Deactivate(); |
|
244 |
|
245 if( iDiscoveryObserver ) |
|
246 { |
|
247 if(KErrNone == aError)// discovery finished, update not-found cached devices |
|
248 UpdateCacheList(); |
|
249 |
|
250 //We're not interested if the call back leaves |
|
251 TRAP_IGNORE(iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, aError)); |
|
252 } |
|
253 |
|
254 LOG("[CBtPrintingDevice::DiscoveryError]\t end"); |
|
255 } |
|
256 |
|
257 //-------------------------------------------------------------------------------------------- |
|
258 // |
|
259 // CBtPrintingDevice::StartDiscoveryL |
|
260 // |
|
261 //-------------------------------------------------------------------------------------------- |
|
262 void CBtPrintingDevice::StartDiscoveryL(MProtDiscoveryObserver& aObserver, TUint aProtocol) |
|
263 { |
|
264 LOG1("[CBtPrintingDevice::StartDiscoveryL]\t aProtocol: %d", aProtocol); |
|
265 iDiscoveryObserver = &aObserver; |
|
266 |
|
267 // already discovering |
|
268 if(EDiscovering == iState) |
|
269 return; |
|
270 |
|
271 if((aProtocol & SupportedProtocols())) |
|
272 { |
|
273 iRequestedProtocols = aProtocol; |
|
274 iDeviceContainer->Reset(); |
|
275 iPrinterController->Stop(); |
|
276 |
|
277 // If GetUsedDevicesL fails, no can do. Just continue. |
|
278 LOG("[CBtPrintingDevice::StartDiscoveryL]\t Get used devices"); |
|
279 TInt leave; |
|
280 TRAP(leave, GetUsedDevicesL() ); |
|
281 LOG1("[CBtPrintingDevice::StartDiscoveryL]\t Get used devices leaves with %d", leave); |
|
282 |
|
283 LOG("[CBtPrintingDevice::StartDiscoveryL]\t Calling iPrinterController"); |
|
284 iPrinterController->StartDiscoveryL(aProtocol); |
|
285 |
|
286 iState = EDiscovering; |
|
287 } |
|
288 else |
|
289 { |
|
290 LOG("CBtPrintingDevice::StartDiscoveryL NO protocol match, ending discovery..."); |
|
291 if( iDiscoveryObserver ) |
|
292 { |
|
293 //We're not interested if the call back leaves |
|
294 TRAP_IGNORE(iDiscoveryObserver->DiscoveryStatusL(EDiscoveryFinished, KErrNone)); |
|
295 } |
|
296 } |
|
297 LOG("[CBtPrintingDevice::StartDiscoveryL]\t end"); |
|
298 } |
|
299 |
|
300 //-------------------------------------------------------------------------------------------- |
|
301 // |
|
302 // CBtPrintingDevice::RemoveCachedDeviceL |
|
303 // |
|
304 //-------------------------------------------------------------------------------------------- |
|
305 TInt CBtPrintingDevice::RemoveCachedDeviceL(TInt aDeviceID) |
|
306 { |
|
307 LOG1("CBtPrintingDevice::RemoveCachedDeviceL aDeviceID: %d", aDeviceID); |
|
308 |
|
309 TInt err = KErrNone; |
|
310 CRsBtDevice* device = FindDevice(aDeviceID); |
|
311 if( device ) |
|
312 { |
|
313 device->SetUsed(EFalse); |
|
314 iDeviceContainer->StoreL(); |
|
315 } |
|
316 else |
|
317 { |
|
318 err = KErrInvalidData; |
|
319 } |
|
320 |
|
321 LOG1("CBtPrintingDevice::RemoveCachedDeviceL end with: %d", err); |
|
322 return err; |
|
323 } |
|
324 |
|
325 //-------------------------------------------------------------------------------------------- |
|
326 // |
|
327 // CBtPrintingDevice::UpdateCacheListL |
|
328 // |
|
329 //-------------------------------------------------------------------------------------------- |
|
330 void CBtPrintingDevice::UpdateCacheList() |
|
331 { |
|
332 LOG("[CBtPrintingDevice::UpdateCacheList]\t"); |
|
333 |
|
334 for(TInt i = 0; i < iDeviceContainer->Count(); ++i) |
|
335 { |
|
336 CRsBtDevice* device = iDeviceContainer->At(i); |
|
337 if(device && !device->IsJustFound()) |
|
338 DeviceDisappeared(*device); |
|
339 } |
|
340 } |
|
341 |
|
342 //-------------------------------------------------------------------------------------------- |
|
343 // |
|
344 // CBtPrintingDevice::CancelDiscovery |
|
345 // |
|
346 //-------------------------------------------------------------------------------------------- |
|
347 void CBtPrintingDevice::CancelDiscovery(TBool aDoCallBack) |
|
348 { |
|
349 LOG1("[CBtPrintingDevice::CancelDiscovery]\t aDoCallBack: %d", aDoCallBack); |
|
350 if(0 < iDeviceContainer->Count()) |
|
351 { |
|
352 iState = EReady; |
|
353 } |
|
354 else |
|
355 { |
|
356 iState = ENone; |
|
357 } |
|
358 iPrinterController->CancelDiscovery(); |
|
359 Deactivate(); |
|
360 |
|
361 if( aDoCallBack && iDiscoveryObserver ) |
|
362 { |
|
363 //We're not interested if the call back leaves |
|
364 TRAP_IGNORE(iDiscoveryObserver->DiscoveryStatusL(EDiscoveryCancelling, KErrNone)); |
|
365 } |
|
366 LOG("[CBtPrintingDevice::CancelDiscovery]\t end"); |
|
367 } |
|
368 |
|
369 //-------------------------------------------------------------------------------------------- |
|
370 // |
|
371 // CBtPrintingDevice::CreatePrintJobL |
|
372 // |
|
373 //-------------------------------------------------------------------------------------------- |
|
374 TInt CBtPrintingDevice::CreatePrintJobL(TInt aDeviceID, RPointerArray<TDesC>& aImages, MProtPrintEventObserver& aObserver) |
|
375 { |
|
376 LOG("[CBtPrintingDevice::CreatePrintJobL]\t begin"); |
|
377 LOG2("[CBtPrintingDevice::CreatePrintJobL]\t aDeviceID: %d, aImages.Count(): %d", aDeviceID, aImages.Count()); |
|
378 |
|
379 iPrintEventObserver = &aObserver; |
|
380 |
|
381 CRsBtDevice *printer = FindDevice( aDeviceID ); |
|
382 |
|
383 if( printer == NULL ) |
|
384 { |
|
385 LOG("CBtPrintingDevice::CreatePrintJobL no device found, returning error"); |
|
386 return KErrInvalidData; |
|
387 } |
|
388 if(iPrintingJob && |
|
389 (CPrintJob::EStateSubmitted == iPrintingJob->JobState() || |
|
390 CPrintJob::EStateSending == iPrintingJob->JobState() || |
|
391 CPrintJob::EStatePrinting == iPrintingJob->JobState()) ) |
|
392 { |
|
393 LOG("[CBtPrintingDevice::CreatePrintJobL]\t Printing job already"); |
|
394 return KErrInvalidSequence; |
|
395 } |
|
396 |
|
397 iPendingCount = 0; |
|
398 |
|
399 GetCapabilities(*printer); |
|
400 |
|
401 InitJobL(printer, aImages); |
|
402 |
|
403 LOG("[CBtPrintingDevice::CreatePrintJobL]\t job created"); |
|
404 |
|
405 iPrintingJob->UpdateJobState(CPrintJob::EStateCreated); |
|
406 |
|
407 LOG1("[CBtPrintingDevice::CreatePrintJobL]\t end - status: %d", iState); |
|
408 |
|
409 return KErrNone; |
|
410 } |
|
411 |
|
412 |
|
413 //-------------------------------------------------------------------------------------------- |
|
414 // |
|
415 // CBtPrintingDevice::SubmitPrintJobL |
|
416 // |
|
417 //-------------------------------------------------------------------------------------------- |
|
418 void CBtPrintingDevice::SubmitPrintJobL() |
|
419 { |
|
420 LOG("[CBtPrintingDevice::SubmitPrintJobL] begin"); |
|
421 |
|
422 TInt err = KErrInvalidSequence; |
|
423 if( iPrintingJob && iPrintingJob->JobState() == CPrintJob::EStateCreated ) |
|
424 { |
|
425 // We try to find the Device specified in our list. |
|
426 CRsBtDevice* device = static_cast<CRsBtDevice*>(User::LeaveIfNull( |
|
427 FindDevice(iPrintingJob->PrinterId()))); |
|
428 |
|
429 LOG1("[CBtPrintingDevice::SubmitPrintJobL] iPrintingJob.iPrinterID: %d", iPrintingJob->PrinterId() ); |
|
430 // save used bluetooth profile |
|
431 iUsedBtProfile = device->UsedProtocol(); |
|
432 if( !(device->UsedProtocol() & SupportedProtocols()) ) |
|
433 { |
|
434 LOG("[CBtPrintingDevice::SubmitPrintJobL]\t can't select a protocol"); |
|
435 err = KErrInvalidData; |
|
436 } |
|
437 else |
|
438 { |
|
439 LOG1("[CBtPrintingDevice::SubmitPrintJobL]\t Submitting to printer \"%S\"", &(device->FriendlyName())); |
|
440 iState = EJobProgress; |
|
441 |
|
442 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
443 iPendingCount = 0; |
|
444 iProggress = 0; |
|
445 |
|
446 TRAP(err, iPrinterController->CreateJobL(*device, *iPrintingJob) ); |
|
447 LOG1("[CBtPrintingDevice::SubmitPrintJobL]\t CreateJobL leaves with %d", err); |
|
448 if(KErrNone == err) |
|
449 { |
|
450 device->SetUsed(ETrue); |
|
451 iDeviceContainer->StoreL(); |
|
452 |
|
453 if( iPrintingJob->JobState() != CPrintJob::EStateSending && |
|
454 iPrintingJob->JobState() != CPrintJob::EStatePrinting ) |
|
455 { |
|
456 iPrintingJob->UpdateJobState(CPrintJob::EStateSubmitted); |
|
457 } |
|
458 |
|
459 } |
|
460 else |
|
461 { |
|
462 CreateJobResponse(KErrNotFound, err); |
|
463 } |
|
464 } |
|
465 } |
|
466 else |
|
467 LOG("[CBtPrintingDevice::SubmitPrintJobL]\t ***Invalid Sequence***. Job state wrong or job not created"); |
|
468 |
|
469 if(KErrNone != err) |
|
470 { |
|
471 LOG1("[CBtPrintingDevice::SubmitPrintJobL]\t return error %d", err); |
|
472 if (iPrintEventObserver) |
|
473 iPrintEventObserver->PrintJobErrorEvent(err); |
|
474 else |
|
475 User::Leave(err); |
|
476 } |
|
477 LOG("[CBtPrintingDevice::SubmitPrintJobL] end"); |
|
478 } |
|
479 |
|
480 //-------------------------------------------------------------------------------------------- |
|
481 // |
|
482 // CBtPrintingDevice::CancelPrintJob |
|
483 // |
|
484 //-------------------------------------------------------------------------------------------- |
|
485 TInt CBtPrintingDevice::CancelPrintJob() |
|
486 { |
|
487 LOG("[CBtPrintingDevice::CancelPrintJob]\t begin"); |
|
488 TInt retVal( KErrInvalidSequence ); |
|
489 |
|
490 LOG1("[CBtPrintingDevice::CancelPrintJob]\t iPrintingJob: %d", iPrintingJob); |
|
491 |
|
492 if(iPrintingJob) |
|
493 { |
|
494 retVal = KErrNone; |
|
495 |
|
496 LOG1("[CBtPrintingDevice::CancelPrintJob]\t iPrintingJob->JobState(): %d", iPrintingJob->JobState()); |
|
497 if(iPrintingJob->JobState() == CPrintJob::EStateCancel) |
|
498 { |
|
499 LOG("[CBtPrintingDevice::CancelPrintJob]\t Already cancelling. Return."); |
|
500 retVal = KErrCancel; |
|
501 } |
|
502 else if( iPrintingJob->JobState() == CPrintJob::EStateSubmitted || |
|
503 iPrintingJob->JobState() == CPrintJob::EStateSending || |
|
504 iPrintingJob->JobState() == CPrintJob::EStatePrinting ) |
|
505 { |
|
506 // cancel job |
|
507 TInt leave; // for remove compiling errors |
|
508 TRAP(leave, CancelJobL()); |
|
509 if( leave == KErrDisconnected ) |
|
510 { |
|
511 LOG("[CBtPrintingDevice::CancelPrintJob]\t calling OPPJobRollBack..."); |
|
512 OPPJobRollBack(); |
|
513 } |
|
514 LOG1("[CBtPrintingDevice::CancelPrintJob]\t CancelJobL() leaves with %d.", leave); |
|
515 } |
|
516 else |
|
517 { |
|
518 LOG1("[CBtPrintingDevice::CancelPrintJob]\t No print job, just cancel all (forced stop) if connections exist: %d", iPrinterController->IsConnected()); |
|
519 FinishPrinting( KErrInvalidSequence ); |
|
520 |
|
521 } |
|
522 } |
|
523 |
|
524 if( iPrintEventObserver ) |
|
525 { |
|
526 iPrintEventObserver->PrintJobProgressEvent( EDone, iPrinterController->GetPercentSent(), ECancelling ); |
|
527 } |
|
528 |
|
529 LOG1("CBtPrintingDevice::CancelPrintJob end with: %d", retVal); |
|
530 return retVal; |
|
531 } |
|
532 |
|
533 //-------------------------------------------------------------------------------------------- |
|
534 // |
|
535 // CBtPrintingDevice::OPPJobRollBack |
|
536 // |
|
537 //-------------------------------------------------------------------------------------------- |
|
538 void CBtPrintingDevice::OPPJobRollBack() |
|
539 { |
|
540 LOG("[CBtPrintingDevice::OPPJobRollBack ]\t begin"); |
|
541 |
|
542 Cancel(); |
|
543 TInt err = KErrNone; |
|
544 iState = EFinish; |
|
545 TRequestStatus* tmpStatus = &iStatus; |
|
546 User::RequestComplete( tmpStatus, err ); |
|
547 SetActive(); |
|
548 |
|
549 LOG("[CBtPrintingDevice::OPPJobRollBack ]\t end"); |
|
550 } |
|
551 |
|
552 |
|
553 //-------------------------------------------------------------------------------------------- |
|
554 // |
|
555 // CBtPrintingDevice::ContinuePrintJobL |
|
556 // |
|
557 //-------------------------------------------------------------------------------------------- |
|
558 TInt CBtPrintingDevice::ContinuePrintJobL() |
|
559 { |
|
560 LOG1("CBtPrintingDevice::ContinuePrintJobL returns with: %d", KErrNotSupported); |
|
561 return KErrNotSupported; |
|
562 } |
|
563 |
|
564 //-------------------------------------------------------------------------------------------- |
|
565 // |
|
566 // CBtPrintingDevice::GetNumPrintPages |
|
567 // |
|
568 //-------------------------------------------------------------------------------------------- |
|
569 TInt CBtPrintingDevice::GetNumPrintPages() |
|
570 { |
|
571 LOG("[CBtPrintingDevice::GetNumPrintPages]\t"); |
|
572 |
|
573 if( iPrintingJob ) |
|
574 return iPrintingJob->Sheets(); |
|
575 else |
|
576 return KErrInvalidSequence; |
|
577 } |
|
578 |
|
579 |
|
580 //-------------------------------------------------------------------------------------------- |
|
581 // |
|
582 // CBtPrintingDevice::GetPrintJobStatus |
|
583 // |
|
584 //-------------------------------------------------------------------------------------------- |
|
585 TInt CBtPrintingDevice::GetPrintJobStatus() |
|
586 { |
|
587 LOG1("CBtPrintingDevice::GetPrintJobStatus returns with: %d", KErrNotSupported); |
|
588 return KErrNotSupported; |
|
589 } |
|
590 |
|
591 //-------------------------------------------------------------------------------------------- |
|
592 // |
|
593 // CBtPrintingDevice::GetPrinterStatus |
|
594 // |
|
595 //-------------------------------------------------------------------------------------------- |
|
596 TInt CBtPrintingDevice::GetPrinterStatus(TInt /*aDeviceID*/) |
|
597 { |
|
598 LOG1("CBtPrintingDevice::GetPrinterStatus returns with: %d", KErrNotSupported); |
|
599 return KErrNotSupported; |
|
600 } |
|
601 |
|
602 |
|
603 //-------------------------------------------------------------------------------------------- |
|
604 // |
|
605 // CBtPrintingDevice::GetDeviceCapabilityIDsL |
|
606 // |
|
607 //-------------------------------------------------------------------------------------------- |
|
608 TInt CBtPrintingDevice::GetDeviceCapabilityIDsL(TInt aDeviceID, RArray<TInt>& aCapabilityIDs) |
|
609 { |
|
610 LOG1("[CBtPrintingDevice::GetDeviceCapabilityIDsL]\t begins with aDeviceID: %d", aDeviceID); |
|
611 |
|
612 TInt err = KErrNone; |
|
613 aCapabilityIDs.Reset(); |
|
614 |
|
615 CRsBtDevice *printer = FindDevice( aDeviceID ); |
|
616 if( printer == NULL ) |
|
617 { |
|
618 LOG("[CBtPrintingDevice::GetDeviceCapabilityIDsL]\t no device found, returning error"); |
|
619 return KErrInvalidData; |
|
620 } |
|
621 |
|
622 GetCapabilities(*printer); |
|
623 |
|
624 printer->GetCapabilityIDs(aCapabilityIDs); |
|
625 |
|
626 LOG1("[CBtPrintingDevice::GetDeviceCapabilityIDsL]\t ends with err: %d", err); |
|
627 return err; |
|
628 } |
|
629 |
|
630 |
|
631 //-------------------------------------------------------------------------------------------- |
|
632 // |
|
633 // CBtPrintingDevice::GetDeviceCapabilityL |
|
634 // |
|
635 //-------------------------------------------------------------------------------------------- |
|
636 TInt CBtPrintingDevice::GetDeviceCapabilityL(TInt aDeviceID, TInt aCapabilityID, TPrintCapability& aCapability) |
|
637 { |
|
638 LOG1("CBtPrintingDevice::GetDeviceCapabilityL begins with aDeviceID: %d", aDeviceID); |
|
639 LOG1("CBtPrintingDevice::GetDeviceCapabilityL begins with aCapabilityID: %d", aCapabilityID); |
|
640 |
|
641 TInt err = KErrNone; |
|
642 |
|
643 CRsBtDevice* printer = FindDevice(aDeviceID); |
|
644 if( printer ) |
|
645 { |
|
646 printer->GetCapability(aCapabilityID, aCapability); |
|
647 } |
|
648 else |
|
649 { |
|
650 err = KErrInvalidData; |
|
651 } |
|
652 LOG1("CBtPrintingDevice::GetDeviceCapabilityL ends with err: %d", err); |
|
653 return err; |
|
654 } |
|
655 |
|
656 |
|
657 //-------------------------------------------------------------------------------------------- |
|
658 // |
|
659 // CBtPrintingDevice::GetJobSetting |
|
660 // |
|
661 //-------------------------------------------------------------------------------------------- |
|
662 TInt CBtPrintingDevice::GetJobSetting(TInt aCapabilityID, TInt& aValue) |
|
663 { |
|
664 LOG1("CBtPrintingDevice::GetJobSetting begins with aCapabilityID: %d", aCapabilityID); |
|
665 |
|
666 TInt res = KErrInvalidSequence; |
|
667 aValue = KErrNotFound; |
|
668 |
|
669 if(iPrintingJob) |
|
670 res = iPrintingJob->GetPrintSetting(aCapabilityID, aValue); |
|
671 |
|
672 return res; |
|
673 } |
|
674 |
|
675 //-------------------------------------------------------------------------------------------- |
|
676 // |
|
677 // CBtPrintingDevice::SetJobSettingL |
|
678 // |
|
679 //-------------------------------------------------------------------------------------------- |
|
680 TInt CBtPrintingDevice::SetJobSettingL(TInt aCapabilityID, TInt aValue, TInt& aAffectedCapability) |
|
681 { |
|
682 LOG1("[CBtPrintingDevice::SetJobSettingL]\t begins with aCapabilityID: %d", aCapabilityID); |
|
683 LOG1("[CBtPrintingDevice::SetJobSettingL]\t begins with aValue: %d", aValue); |
|
684 LOG1("[CBtPrintingDevice::SetJobSettingL]\t begins with aAffectedCapability: %d", aAffectedCapability); |
|
685 |
|
686 if( !iPrintingJob || iPrintingJob->JobState() == CPrintJob::EStateNone ) |
|
687 { |
|
688 LOG1("[CBtPrintingDevice::SetJobSettingL]\t iPrintingJob: %d || job state == EJobStateNone; return KErrInvalidSequence", iPrintingJob); |
|
689 return KErrInvalidSequence; |
|
690 } |
|
691 |
|
692 aAffectedCapability = 0; |
|
693 |
|
694 // Get the Target printer and capability |
|
695 CRsBtDevice* printer = FindDevice( iPrintingJob->PrinterId() ); |
|
696 if( printer == NULL ) |
|
697 { |
|
698 LOG1("[CBtPrintingDevice::SetJobSettingL]\t printer == NULL; return %d", KErrInvalidData); |
|
699 return KErrInvalidData; |
|
700 } |
|
701 |
|
702 TInt res = printer->SetDefaultCapability(aCapabilityID, aValue); |
|
703 if(KErrNone == res) |
|
704 { |
|
705 iPrintingJob->SetPrintSetting(aCapabilityID, aValue); |
|
706 aAffectedCapability = aCapabilityID; |
|
707 TRAPD(err, iDeviceContainer->StoreL()); |
|
708 if(KErrNone != err) |
|
709 { |
|
710 LOG1("[CBtPrintingDevice::SetJobSettingL]\t Storing fails: %d", err); |
|
711 } |
|
712 } |
|
713 LOG1("[CBtPrintingDevice::SetJobSettingL]\t ends. aAffectedCapability: %d", aAffectedCapability); |
|
714 return res; |
|
715 } |
|
716 |
|
717 |
|
718 //-------------------------------------------------------------------------------------------- |
|
719 // |
|
720 // CBtPrintingDevice::GetNumPreviewPages |
|
721 // |
|
722 //-------------------------------------------------------------------------------------------- |
|
723 TInt CBtPrintingDevice::GetNumPreviewPages() |
|
724 { |
|
725 LOG1("CBtPrintingDevice::GetNumPreviewPages ends with: %d", 1); |
|
726 return 1; |
|
727 } |
|
728 |
|
729 //-------------------------------------------------------------------------------------------- |
|
730 // |
|
731 // CBtPrintingDevice::GetJobTemplateIconL |
|
732 // |
|
733 //-------------------------------------------------------------------------------------------- |
|
734 TInt CBtPrintingDevice::GetJobTemplateIconL(TInt /*aTemplateID*/, TInt& /*aFsBitmapHandle*/) |
|
735 { |
|
736 return KErrNone; |
|
737 } |
|
738 |
|
739 //-------------------------------------------------------------------------------------------- |
|
740 // |
|
741 // CBtPrintingDevice::CreatePreviewImage |
|
742 // |
|
743 //-------------------------------------------------------------------------------------------- |
|
744 TInt CBtPrintingDevice::CreatePreviewImage(TInt /*aPageNumber*/) |
|
745 { |
|
746 return KErrNone; |
|
747 } |
|
748 |
|
749 //-------------------------------------------------------------------------------------------- |
|
750 // |
|
751 // CBtPrintingDevice::CreateJobResponse |
|
752 // |
|
753 //-------------------------------------------------------------------------------------------- |
|
754 void CBtPrintingDevice::CreateJobResponse( TInt aJobId, TInt aErrorCode ) |
|
755 { |
|
756 LOG2("[CBtPrintingDevice::CreateJobResponse]\t iState: %d, Error: %d", iState, aErrorCode); |
|
757 |
|
758 ResetTimer(); |
|
759 |
|
760 if (ECancelJob == iState) |
|
761 { |
|
762 LOG2("[CBtPrintingDevice::CreateJobResponse]\t wrong sequence: iState: %d, iPrintingJob->JobState(): %d", iState, iPrintingJob->JobState()); |
|
763 return; |
|
764 } |
|
765 |
|
766 if(KErrNone != aErrorCode) |
|
767 { |
|
768 LOG1("[CBtPrintingDevice::CreateJobResponse]\t error occured: %d. Finish.", aErrorCode); |
|
769 ManagePrintingState(KErrNotFound, EBtStateAborted, EBtStateIdle, KErrNone, aErrorCode); |
|
770 return; |
|
771 } |
|
772 |
|
773 iPrintingJob->SetJobId(aJobId); |
|
774 |
|
775 iState = EJobProgress; |
|
776 |
|
777 LOG( "[CBtPrintingDevice]\t ******"); |
|
778 LOG1("[CBtPrintingDevice]\t -Printing started with job id: * %2d", aJobId); |
|
779 LOG( "[CBtPrintingDevice]\t ******"); |
|
780 |
|
781 // Printing started - restart timer |
|
782 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
783 |
|
784 } |
|
785 |
|
786 //-------------------------------------------------------------------------------------------- |
|
787 // |
|
788 // CBtPrintingDevice::CancelJobResponse |
|
789 // |
|
790 //-------------------------------------------------------------------------------------------- |
|
791 void CBtPrintingDevice::CancelJobResponse(TInt aErrorCode ) |
|
792 { |
|
793 LOG1("[CUPnPPrintingDevice::CancelJobResponse]\t Error: %d", aErrorCode); |
|
794 ManagePrintingState(iPrintingJob->JobId(), EBtStateCancelled, EBtStateIdle, KErrNone, aErrorCode); |
|
795 |
|
796 } |
|
797 |
|
798 //-------------------------------------------------------------------------------------------- |
|
799 // |
|
800 // CBtPrintingDevice::GetPrinterStateResponse |
|
801 // |
|
802 //-------------------------------------------------------------------------------------------- |
|
803 void CBtPrintingDevice::GetPrinterStateResponse(TInt aState, TInt aStateReasons, |
|
804 TInt aOperationStatus, TInt aDeviceId) |
|
805 { |
|
806 LOG2("[CBtPrintingDevice::GetPrinterStateResponse]\t iState: %d, Error: %d", iState, aOperationStatus); |
|
807 |
|
808 if(EGetPrinterState != iState) |
|
809 return; |
|
810 |
|
811 Deactivate(); |
|
812 |
|
813 CRsBtDevice* printer = FindDevice( aDeviceId ); |
|
814 if(!printer) |
|
815 { |
|
816 LOG("[CBtPrintingDevice::GetPrinterStateResponse]\t panic PANIC panic: printer not found"); |
|
817 return; |
|
818 } |
|
819 |
|
820 LOG2("[CBtPrintingDevice::GetPrinterStateResponse] Printer state: %d - %d", aState, aOperationStatus); |
|
821 if(KErrNone != aOperationStatus) |
|
822 { |
|
823 // handle operation status in ManagePrintingState as a printer state |
|
824 aState = EBtStateStopped; |
|
825 aStateReasons = aOperationStatus; |
|
826 } |
|
827 |
|
828 if(EBtStateStopped == aState) |
|
829 { |
|
830 ManagePrintingState(KErrNotFound, EBtStateUnknown, aState, aStateReasons, aOperationStatus); |
|
831 return; |
|
832 } |
|
833 else if (EBtStateIdle == aState) |
|
834 { |
|
835 // maybe we cannot touch to iState: it maybe set to somethin on purpose... |
|
836 //iState = EReady; |
|
837 } |
|
838 } |
|
839 |
|
840 //-------------------------------------------------------------------------------------------- |
|
841 // |
|
842 // CBtPrintingDevice::GetEventResponse |
|
843 // |
|
844 //-------------------------------------------------------------------------------------------- |
|
845 void CBtPrintingDevice::GetEventResponse(TInt aJobId, TInt aJobState, TInt aPrinterState, |
|
846 TInt aStateReasons, TInt aOperationStatus) |
|
847 { |
|
848 LOG("[CBtPrintingDevice::GetEventResponse]\t"); |
|
849 |
|
850 ManagePrintingState(aJobId, aJobState, aPrinterState, aStateReasons, aOperationStatus); |
|
851 } |
|
852 |
|
853 //-------------------------------------------------------------------------------------------- |
|
854 // |
|
855 // CBtPrintingDevice::GetJobAttributesResponse |
|
856 // |
|
857 //-------------------------------------------------------------------------------------------- |
|
858 void CBtPrintingDevice::GetJobAttributesResponse( TInt aJobState, |
|
859 const TDesC8& aJobName, |
|
860 const TDesC8& /*aOriginator*/, |
|
861 TInt aSheetsCompleted, |
|
862 TInt aPendingJobs, |
|
863 TInt aOperationStatus ) |
|
864 { |
|
865 |
|
866 LOG1("[CBtPrintingDevice::GetJobAttributesResponse]\t iState: %d", iState); |
|
867 LOG2("[CBtPrintingDevice::GetJobAttributesResponse]\t aOperationStatus: %d / 0x%X", aOperationStatus, aOperationStatus); |
|
868 LOG2("[CBtPrintingDevice::GetJobAttributesResponse]\t aJobState: %d aSheetsCompleted: %d", aJobState, aSheetsCompleted); |
|
869 LOG82("[CBtPrintingDevice::GetJobAttributesResponse]\t aPendingJobs: %d aJobName: %S", aPendingJobs, &aJobName); |
|
870 |
|
871 if(EFinish == iState) |
|
872 { |
|
873 LOG("[CBtPrintingDevice::GetJobAttributesResponse]\t Finishing... return."); |
|
874 return; |
|
875 } |
|
876 |
|
877 if(KErrNone == aOperationStatus) |
|
878 { |
|
879 LOG("[CBtPrintingDevice::GetJobAttributesResponse]\t aOperationStatus OK"); |
|
880 |
|
881 if(0 < aPendingJobs) |
|
882 { |
|
883 LOG1("[CBtPrintingDevice::GetJobAttributesResponse]\t pending: %d", aPendingJobs); |
|
884 aJobState = EBtStateWaiting; |
|
885 } |
|
886 else if(iPrintingJob->Sheets() == aSheetsCompleted) |
|
887 { |
|
888 LOG("[CBtPrintingDevice::GetJobAttributesResponse]\t Job Completed."); |
|
889 aJobState = EBtStateCompleted; |
|
890 |
|
891 if(CPrintJob::EStateCancel == iPrintingJob->JobState()) |
|
892 iPrintingJob->UpdateJobState(CPrintJob::EStatePrinting); |
|
893 } |
|
894 else if(KPendingLimit == iPendingCount) |
|
895 { |
|
896 LOG1("[CBtPrintingDevice::GetJobAttributesResponse]\t timeout. pending too long: %d", iPendingCount); |
|
897 aOperationStatus = EPbCheckPrinter; |
|
898 } |
|
899 else if (aJobState == EBtStateStopped || aJobState == EBtStateAborted || aJobState == EBtStateUnknown || aJobState == EBtStateWaiting || aJobState == EBtStateCompleted) |
|
900 { |
|
901 Deactivate(); |
|
902 |
|
903 LOG1("[CBtPrintingDevice::GetJobAttributesResponse]\t aJobState NOK: %d. Get printer attributes", aJobState); |
|
904 TRequestStatus* tmpStatus = &iStatus; |
|
905 iState = EGetPrinterState; |
|
906 User::RequestComplete(tmpStatus, KErrNone); |
|
907 |
|
908 SetActive(); |
|
909 return; |
|
910 } |
|
911 else |
|
912 { |
|
913 iState = EGetJobAttributes; |
|
914 aJobState = EBtStatePrinting; |
|
915 } |
|
916 } |
|
917 |
|
918 ManagePrintingState(iPrintingJob->JobId(), aJobState, EBtStatePrinting, ENoMessage, aOperationStatus); |
|
919 |
|
920 return; |
|
921 } |
|
922 |
|
923 |
|
924 //-------------------------------------------------------------------------------------------- |
|
925 // |
|
926 // CBtPrintingDevice::FindDevice |
|
927 // |
|
928 //-------------------------------------------------------------------------------------------- |
|
929 CRsBtDevice* CBtPrintingDevice::FindDevice(TInt aDeviceID) |
|
930 { |
|
931 LOG1("[CBtPrintingDevice::FindDevice] begins with aDeviceID: %d", aDeviceID); |
|
932 TInt pos = iDeviceContainer->Find(aDeviceID); |
|
933 if(KErrNotFound != pos) |
|
934 { |
|
935 return iDeviceContainer->At(pos); |
|
936 } |
|
937 LOG("[CBtPrintingDevice::FindDevice] device NOT found"); |
|
938 return NULL; |
|
939 } |
|
940 |
|
941 //-------------------------------------------------------------------------------------------- |
|
942 // |
|
943 // CBtPrintingDevice::SetNumsOfCopiesL |
|
944 // |
|
945 //-------------------------------------------------------------------------------------------- |
|
946 void CBtPrintingDevice::SetNumsOfCopiesL( const RArray<TInt>& aNumsOfCopies, TInt& aErr ) |
|
947 { |
|
948 if( !iPrintingJob || iPrintingJob->JobState() != CPrintJob::EStateCreated ) |
|
949 { |
|
950 aErr = KErrInvalidSequence; |
|
951 return; |
|
952 } |
|
953 |
|
954 LOG1("[CBtPrintingDevice::SetNumsOfCopiesL]\t iPrintingJob->JobState(): %d", iPrintingJob->JobState()); |
|
955 |
|
956 LOG2("[CBtPrintingDevice::SetNumsOfCopiesL]\t ImageCount(): %d, copies count: %d ", |
|
957 iPrintingJob->ImageCount(), aNumsOfCopies.Count()); |
|
958 if( iPrintingJob->ImageCount() != aNumsOfCopies.Count() ) |
|
959 { |
|
960 aErr = KErrInvalidData; |
|
961 return; |
|
962 } |
|
963 |
|
964 aErr = iPrintingJob->SetNumsOfCopies(aNumsOfCopies); |
|
965 LOG1("CBtPrintingDevice::SetNumsOfCopiesL aErr: %d", aErr); |
|
966 } |
|
967 |
|
968 //-------------------------------------------------------------------------------------------- |
|
969 // |
|
970 // CBtPrintingDevice::InitJobL |
|
971 // |
|
972 //-------------------------------------------------------------------------------------------- |
|
973 void CBtPrintingDevice::InitJobL(CRsBtDevice *aPrinter, RPointerArray<TDesC>& aImages) |
|
974 { |
|
975 LOG("[CBtPrintingDevice::InitJobL]"); |
|
976 |
|
977 if (iPrintingJob) |
|
978 { |
|
979 delete iPrintingJob; |
|
980 iPrintingJob = NULL; |
|
981 } |
|
982 |
|
983 // Change format of file list |
|
984 RArray<TFileName> imageList; |
|
985 CleanupClosePushL(imageList); |
|
986 for (TInt i=0; i < aImages.Count(); i++) |
|
987 { |
|
988 LOG1("[InitJobL]\t %S", aImages[i]); |
|
989 imageList.Append( *(aImages[i]) ); |
|
990 } |
|
991 |
|
992 // Get local BT name |
|
993 TBuf8<0x100> name; |
|
994 GetLocalBTNameL(name); |
|
995 |
|
996 // Create job object |
|
997 iPrintingJob = CPrintJob::NewL(aPrinter, imageList, name); |
|
998 CleanupStack::PopAndDestroy(&imageList); |
|
999 |
|
1000 RArray<TInt> capabIDs; |
|
1001 CleanupClosePushL(capabIDs); |
|
1002 aPrinter ->GetCapabilityIDs(capabIDs); |
|
1003 |
|
1004 for(TInt i = 0; i < capabIDs.Count(); ++i) |
|
1005 { |
|
1006 TPrintCapability capab; |
|
1007 aPrinter->GetCapability(capabIDs[i], capab); |
|
1008 iPrintingJob->SetPrintSetting(capabIDs[i], capab.iDefaultValue); |
|
1009 } |
|
1010 CleanupStack::PopAndDestroy(&capabIDs); |
|
1011 |
|
1012 } |
|
1013 |
|
1014 //-------------------------------------------------------------------------------------------- |
|
1015 // |
|
1016 // CBtPrintingDevice::GetCapabilities |
|
1017 // |
|
1018 //-------------------------------------------------------------------------------------------- |
|
1019 void CBtPrintingDevice::GetCapabilities(CRsBtDevice& aPrinter, TBool aForcedGet) |
|
1020 { |
|
1021 // gets printer capabilities. If cannot get, sets defaults. |
|
1022 LOG1("[CBtPrintingDevice::GetCapabilities] already found %d", aPrinter.CapabilityCount()); |
|
1023 |
|
1024 // Capabilities already got |
|
1025 if (0 < aPrinter.CapabilityCount() && !aForcedGet ) |
|
1026 return; |
|
1027 |
|
1028 TDeviceState tmpState = iState; |
|
1029 iPendingCount = 0; |
|
1030 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
1031 |
|
1032 /*Get printer's capabilities*/ |
|
1033 TRAPD(leave, iPrinterController->GetCapabilitiesL(aPrinter) ); |
|
1034 LOG1("[CBtPrintingDevice::GetCapabilities] GetCapabilitiesL leaves with %d", leave); |
|
1035 |
|
1036 if ( ( leave == KErrNotFound && aPrinter.UsedProtocol() == KImagePrint_PrinterProtocol_BPP ) || |
|
1037 ( leave == KErrArgument && aPrinter.UsedProtocol() == KImagePrint_PrinterProtocol_BPP ) ) |
|
1038 { |
|
1039 LOG( "Capabilities not received from BPP Printer - Thus Force OPP ON to avoid problems "); |
|
1040 LOG( "This case indicates that there is possible problem in the BPP printer. "); |
|
1041 aPrinter.SetUsedProtocol( KImagePrint_PrinterProtocol_OPP_Printer ); |
|
1042 aPrinter.SetSupportedProtocols( KImagePrint_PrinterProtocol_OPP_Printer ); |
|
1043 iUsedBtProfile = KImagePrint_PrinterProtocol_OPP_Printer; |
|
1044 leave = KErrNone; |
|
1045 } |
|
1046 ResetTimer(); |
|
1047 iPendingCount = 0; |
|
1048 iState = tmpState; |
|
1049 |
|
1050 if(KErrNone != leave) |
|
1051 { |
|
1052 // cleanup connections |
|
1053 Cancel(); |
|
1054 iPrinterController->Stop(); |
|
1055 |
|
1056 RArray<TPrintCapability> c; |
|
1057 GetDefaultCapabilities(c); |
|
1058 for (TInt i = 0; i < c.Count(); ++i) |
|
1059 { |
|
1060 aPrinter.AddCapability(c[i]); |
|
1061 } |
|
1062 c.Close(); |
|
1063 } |
|
1064 else |
|
1065 { |
|
1066 // store connected printer |
|
1067 aPrinter.SetUsed(ETrue); |
|
1068 // If this fails, no can do. Continue. |
|
1069 TRAP_IGNORE( iDeviceContainer->StoreL() ); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 //-------------------------------------------------------------------------------------------- |
|
1074 // |
|
1075 // CBtPrintingDevice::GetDefaultCapabilities |
|
1076 // |
|
1077 //-------------------------------------------------------------------------------------------- |
|
1078 void CBtPrintingDevice::GetDefaultCapabilities(RArray<TPrintCapability>& aCapabilities) |
|
1079 { |
|
1080 // Layout |
|
1081 TPrintCapability layout; |
|
1082 layout.iCapabilityID = EPrintCapabLayout; |
|
1083 layout.iType = TPrintCapability::Enum; |
|
1084 layout.iDefaultValue = EPrintCapabLayout1Up; |
|
1085 layout.iLow = 0; |
|
1086 layout.iHigh = 0; |
|
1087 layout.iEnumCodes[0] = layout.iDefaultValue; |
|
1088 layout.iEnumCount = 1; |
|
1089 |
|
1090 // Quality |
|
1091 TPrintCapability quality; |
|
1092 quality.iCapabilityID = EPrintCapabQuality; |
|
1093 quality.iType = TPrintCapability::Enum; |
|
1094 quality.iDefaultValue = EPrintCapabQualityDefault; |
|
1095 quality.iLow = 0; |
|
1096 quality.iHigh = 0; |
|
1097 quality.iEnumCodes[0] = quality.iDefaultValue; |
|
1098 quality.iEnumCount = 1; |
|
1099 |
|
1100 // Paper size |
|
1101 TPrintCapability paper; |
|
1102 paper.iCapabilityID = EPrintCapabPaperSize; |
|
1103 paper.iType = TPrintCapability::Enum; |
|
1104 paper.iDefaultValue = EPrintCapabPaperSizeAuto; |
|
1105 paper.iLow = 0; |
|
1106 paper.iHigh = 0; |
|
1107 paper.iEnumCodes[0] = paper.iDefaultValue; |
|
1108 paper.iEnumCount = 1; |
|
1109 |
|
1110 aCapabilities.Append(layout); |
|
1111 aCapabilities.Append(quality); |
|
1112 aCapabilities.Append(paper); |
|
1113 |
|
1114 } |
|
1115 |
|
1116 //-------------------------------------------------------------------------------------------- |
|
1117 // |
|
1118 // CBtPrintingDevice::FoundDevice |
|
1119 // |
|
1120 //-------------------------------------------------------------------------------------------- |
|
1121 void CBtPrintingDevice::FoundDeviceL(CRsBtDevice& aDevice) |
|
1122 { |
|
1123 LOG2("[CBtPrintingDevice::FoundDeviceL]\t protocol: %d, DeviceId: %d", aDevice.UsedProtocol(), aDevice.DeviceId()); |
|
1124 |
|
1125 TBool inform = EFalse; |
|
1126 |
|
1127 if( aDevice.UsedProtocol() == KImagePrint_PrinterProtocol_BPP ) |
|
1128 { |
|
1129 inform = ETrue; |
|
1130 } |
|
1131 else if( aDevice.UsedProtocol() == KImagePrint_PrinterProtocol_OPP_Printer ) |
|
1132 { |
|
1133 inform = ETrue; |
|
1134 } |
|
1135 else if( aDevice.UsedProtocol() == KImagePrint_PrinterProtocol_OPP_PC ) |
|
1136 { |
|
1137 inform = ETrue; |
|
1138 } |
|
1139 else |
|
1140 { |
|
1141 // avoid lint error |
|
1142 inform = EFalse; |
|
1143 } |
|
1144 |
|
1145 |
|
1146 if( iDiscoveryObserver && inform) |
|
1147 { |
|
1148 TPrinter printer = aDevice.ToTPrinter(); |
|
1149 iDiscoveryObserver->FoundDeviceL( printer ); |
|
1150 LOG("[CBtPrintingDevice::FoundDeviceL] observer informed"); |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 //-------------------------------------------------------------------------------------------- |
|
1155 // |
|
1156 // CBtPrintingDevice::AddBtDeviceL |
|
1157 // |
|
1158 //-------------------------------------------------------------------------------------------- |
|
1159 TInt CBtPrintingDevice::AddBtDeviceL(CRsBtDevice& aDevice) |
|
1160 { |
|
1161 |
|
1162 LOG("[CBtPrintingDevice::AddBtDeviceL]\t"); |
|
1163 |
|
1164 CRsBtDevice* device = NULL; |
|
1165 |
|
1166 TInt pos = iDeviceContainer->Find(aDevice); |
|
1167 LOG1("[CBtPrintingDevice::AddBtDeviceL]\t pos: %d", pos); |
|
1168 if(KErrNotFound != pos) |
|
1169 { |
|
1170 LOG("[CBtPrintingDevice::AddBtDeviceL]\t device exists"); |
|
1171 device = iDeviceContainer->At(pos); |
|
1172 // create TPrinter of old device for informing of update |
|
1173 TPrinter oldPrinter = device->ToTPrinter(); |
|
1174 |
|
1175 // update existing |
|
1176 TBool modified = device->UpdateUsedL(aDevice); |
|
1177 device->SetJustFound(ETrue); |
|
1178 |
|
1179 // Be sure the if updated device is updated in observer |
|
1180 if( iDiscoveryObserver && modified) |
|
1181 { |
|
1182 iDiscoveryObserver->RemoveDeviceL( oldPrinter ); |
|
1183 LOG1("[CBtPrintingDevice::FoundDeviceL] observer informed: remove \"%S\"", &oldPrinter.iDisplayName); |
|
1184 TPrinter printer = device->ToTPrinter(); |
|
1185 iDiscoveryObserver->FoundDeviceL( printer ); |
|
1186 LOG1("[CBtPrintingDevice::FoundDeviceL] observer informed: found \"%S\"", &printer.iDisplayName); |
|
1187 } |
|
1188 |
|
1189 return KErrNone; |
|
1190 } |
|
1191 |
|
1192 device = CRsBtDevice::NewL(aDevice); |
|
1193 LOG1("[CBtPrintingDevice::AddBtDeviceL]\t newDevice address: %d", (TInt)device); |
|
1194 |
|
1195 device->SetUsed(EFalse); |
|
1196 device->SetDisappeared(EFalse); |
|
1197 device->ComposeUsedProtocol(iRequestedProtocols); |
|
1198 |
|
1199 LOG1("[CBtPrintingDevice::AddBtDeviceL]\t usedProtocol: %d", device->UsedProtocol()); |
|
1200 |
|
1201 iDeviceContainer->AppendL(device); |
|
1202 |
|
1203 LOG("[CBtPrintingDevice::AddBtDeviceL]\t preparing info for observer"); |
|
1204 |
|
1205 FoundDeviceL( *device ); |
|
1206 return KErrNone; |
|
1207 } |
|
1208 //-------------------------------------------------------------------------------------------- |
|
1209 // |
|
1210 // CBtPrintingDevice::GetUsedDevicesL |
|
1211 // |
|
1212 //-------------------------------------------------------------------------------------------- |
|
1213 void CBtPrintingDevice::GetUsedDevicesL() |
|
1214 { |
|
1215 LOG("[CBtPrintingDevice::GetUsedDevicesL]\t"); |
|
1216 iDeviceContainer->RestoreL(); |
|
1217 |
|
1218 LOG1("[CBtPrintingDevice::GetUsedDevicesL]\t found %d devices.", iDeviceContainer->Count()); |
|
1219 for(TInt i = 0; i < iDeviceContainer->Count(); ++i) |
|
1220 { |
|
1221 iDeviceContainer->At(i)->ComposeUsedProtocol(iRequestedProtocols); |
|
1222 FoundDeviceL( *(iDeviceContainer->At(i)) ); |
|
1223 } |
|
1224 } |
|
1225 |
|
1226 //-------------------------------------------------------------------------------------------- |
|
1227 // |
|
1228 // CBtPrintingDevice::FinishPrinting |
|
1229 // |
|
1230 //-------------------------------------------------------------------------------------------- |
|
1231 void CBtPrintingDevice::FinishPrinting(TInt aErrorCode) |
|
1232 { |
|
1233 LOG("[CBtPrintingDevice::FinishPrinting]\t "); |
|
1234 |
|
1235 iState = EFinish; |
|
1236 |
|
1237 LOG("[CBtPrintingDevice::FinishPrinting]\t -Reset timer"); |
|
1238 Deactivate(); |
|
1239 |
|
1240 LOG("[CBtPrintingDevice::FinishPrinting]\t -Init ids"); |
|
1241 iPendingCount = KPendingLimit; |
|
1242 |
|
1243 // if error occures when geting capabilities, the job not created yet. |
|
1244 if(iPrintingJob) |
|
1245 { |
|
1246 //Cancel job. if leaves, there is no chance to cancel the job -> continue |
|
1247 //else return, the timeout or cancel job response will complete finish |
|
1248 TRAPD(leave, CancelJobL()); |
|
1249 if(KErrNone != leave) |
|
1250 LOG1("[CBtPrintingDevice::FinishPrinting]\t -CancelJobL() leaves with %d", leave); |
|
1251 else |
|
1252 return; |
|
1253 |
|
1254 iPrintingJob->UpdateJobState(CPrintJob::EStateCreated); |
|
1255 } |
|
1256 |
|
1257 LOG1("[CBtPrintingDevice::FinishPrinting]\t FinishPrinting: state=%d", iState); |
|
1258 |
|
1259 // Inform controller |
|
1260 iPrinterController->FinishPrinting(); |
|
1261 |
|
1262 if(KErrNone != aErrorCode) |
|
1263 { |
|
1264 if (iPrintEventObserver) |
|
1265 iPrintEventObserver->PrintJobErrorEvent(aErrorCode); |
|
1266 } |
|
1267 |
|
1268 iState = EReady; |
|
1269 LOG("[CBtPrintingDevice::FinishPrinting]\t -out"); |
|
1270 } |
|
1271 |
|
1272 |
|
1273 //-------------------------------------------------------------------------------------------- |
|
1274 // |
|
1275 // CBtPrintingDevice::DeviceDiscovered |
|
1276 // |
|
1277 //-------------------------------------------------------------------------------------------- |
|
1278 void CBtPrintingDevice::DeviceDiscovered( CRsBtDevice& aDevice ) |
|
1279 { |
|
1280 LOG("[CBtPrintingDevice::DeviceDiscovered]\t"); |
|
1281 TInt err; // for remove compiling errors |
|
1282 TRAP(err, AddBtDeviceL(aDevice)); |
|
1283 LOG1("[CBtPrintingDevice::DeviceDiscovered]\t Device added with leave: %d", err); |
|
1284 } |
|
1285 |
|
1286 //-------------------------------------------------------------------------------------------- |
|
1287 // |
|
1288 // CBtPrintingDevice::DeviceDisappeared |
|
1289 // |
|
1290 //-------------------------------------------------------------------------------------------- |
|
1291 void CBtPrintingDevice::DeviceDisappeared( CRsBtDevice& aDevice ) |
|
1292 { |
|
1293 LOG("[CBtPrintingDevice::DeviceDisappeared]\t"); |
|
1294 |
|
1295 CRsBtDevice* device = FindDevice(aDevice.DeviceId()); |
|
1296 if(!device) |
|
1297 { |
|
1298 LOG("[CBtPrintingDevice::DeviceDisappeared]\t Device not found. Return."); |
|
1299 return; |
|
1300 } |
|
1301 |
|
1302 TPrinter printer = device->ToTPrinter(); |
|
1303 LOG1("[CBtPrintingDevice::DeviceDisappeared]\t printer.iDisplayName: %S", &(printer.iDisplayName)); |
|
1304 device->SetDisappeared(ETrue); |
|
1305 |
|
1306 // Ignore leave; the call back |
|
1307 TRAP_IGNORE(iDiscoveryObserver->RemoveDeviceL(printer)); |
|
1308 |
|
1309 LOG("[CBtPrintingDevice::DeviceDisappeared]\t end"); |
|
1310 } |
|
1311 |
|
1312 //-------------------------------------------------------------------------------------------- |
|
1313 // |
|
1314 // CBtPrintingDevice::ResetTimer |
|
1315 // |
|
1316 //-------------------------------------------------------------------------------------------- |
|
1317 void CBtPrintingDevice::ResetTimer() |
|
1318 { |
|
1319 LOG("[CBtPrintingDevice::ResetTimer]\t"); |
|
1320 |
|
1321 if(iPrinterTimer) |
|
1322 { |
|
1323 if(iPrinterTimer->IsActive()) |
|
1324 iPrinterTimer->Cancel(); |
|
1325 } |
|
1326 iPendingCount = 0; |
|
1327 } |
|
1328 |
|
1329 //-------------------------------------------------------------------------------------------- |
|
1330 // |
|
1331 // CBtPrintingDevice::StartTimer |
|
1332 // |
|
1333 //-------------------------------------------------------------------------------------------- |
|
1334 void CBtPrintingDevice::StartTimer(TTimeIntervalMicroSeconds32 aDelay, |
|
1335 TTimeIntervalMicroSeconds32 anInterval, |
|
1336 TCallBack aCallBack) |
|
1337 { |
|
1338 LOG("[CBtPrintingDevice::StartTimer]\t"); |
|
1339 |
|
1340 ResetTimer(); |
|
1341 |
|
1342 iPrinterTimer->Start(aDelay, anInterval, aCallBack); |
|
1343 |
|
1344 } |
|
1345 |
|
1346 //-------------------------------------------------------------------------------------------- |
|
1347 // |
|
1348 // CBtPrintingDevice::ConnectionTimeout |
|
1349 // |
|
1350 //-------------------------------------------------------------------------------------------- |
|
1351 TBool CBtPrintingDevice::HandleTimeout(TAny *aWho) |
|
1352 { |
|
1353 CBtPrintingDevice *cbTarget = static_cast<CBtPrintingDevice*>(aWho); |
|
1354 return cbTarget->DoHandleTimeout(); |
|
1355 } |
|
1356 |
|
1357 //-------------------------------------------------------------------------------------------- |
|
1358 // |
|
1359 // CBtPrintingDevice::DoConnectionTimeout |
|
1360 // |
|
1361 //-------------------------------------------------------------------------------------------- |
|
1362 TBool CBtPrintingDevice::DoHandleTimeout() |
|
1363 { |
|
1364 LOG1("[CBtPrintingDevice::DoHandleTimeout]\t iState: %d", iState); |
|
1365 |
|
1366 TInt err = KErrTimedOut; |
|
1367 if(iUsedBtProfile != KImagePrint_PrinterProtocol_OPP_Printer) |
|
1368 { |
|
1369 if(KPendingLimit > iPendingCount) |
|
1370 { |
|
1371 ++iPendingCount; |
|
1372 LOG1("[CBtPrintingDevice::DoHandleTimeout]\t pending: %d", iPendingCount); |
|
1373 |
|
1374 //Continue waiting... |
|
1375 return ETrue; |
|
1376 } |
|
1377 |
|
1378 // when timeout occures during printing, try anyway get printer state |
|
1379 if(KPendingLimit == iPendingCount && EJobProgress == iState) |
|
1380 { |
|
1381 err = KErrNone; |
|
1382 iState = EGetJobAttributes; |
|
1383 --iPendingCount; |
|
1384 } |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 |
|
1389 if(KOppPendingLimit > iPendingCount) |
|
1390 { |
|
1391 ++iPendingCount; |
|
1392 LOG1("[CBtPrintingDevice::DoHandleTimeout]\t opp print pending: %d", iPendingCount); |
|
1393 |
|
1394 //Continue waiting... |
|
1395 return ETrue; |
|
1396 } |
|
1397 |
|
1398 // when timeout occures during printing, try anyway get printer state |
|
1399 if(KOppPendingLimit == iPendingCount && EJobProgress == iState) |
|
1400 { |
|
1401 err = KErrNone; |
|
1402 iState = EFinish; |
|
1403 --iPendingCount; |
|
1404 } |
|
1405 } |
|
1406 |
|
1407 Cancel(); |
|
1408 |
|
1409 TRequestStatus* tmpStatus = &iStatus; |
|
1410 User::RequestComplete(tmpStatus, err); |
|
1411 SetActive(); |
|
1412 |
|
1413 return EFalse; |
|
1414 } |
|
1415 |
|
1416 //-------------------------------------------------------------------------------------------- |
|
1417 // |
|
1418 // CBtPrintingDevice::ManagePrintingState |
|
1419 // |
|
1420 //-------------------------------------------------------------------------------------------- |
|
1421 void CBtPrintingDevice::ManagePrintingState(TInt aJobId, TInt aJobState, TInt aPrinterState, |
|
1422 TInt aStateReasons, TInt aOperationStatus) |
|
1423 { |
|
1424 LOG1("[CBtPrintingDevice::ManagePrintingState]\t begin: iState: %d", iState); |
|
1425 LOG2("[CBtPrintingDevice::ManagePrintingState]\t aOperationStatus: %d / 0x%X", aOperationStatus, aOperationStatus); |
|
1426 LOG2("[CBtPrintingDevice::ManagePrintingState]\t jobId: %d state: %d", aJobId, aJobState); |
|
1427 LOG2("[CBtPrintingDevice::ManagePrintingState]\t aPrinterState: %d aStateReasons: %d", aPrinterState, aStateReasons); |
|
1428 |
|
1429 // already stopping, cancelling or idle... No reason to continue |
|
1430 if( EFinish == iState || EReady == iState ) |
|
1431 return; |
|
1432 |
|
1433 Deactivate(); |
|
1434 TInt percents = 0; |
|
1435 |
|
1436 // Always inform anyway. No matter the state. |
|
1437 // First the error cases: |
|
1438 TInt err = KErrNone; |
|
1439 |
|
1440 // Set tmpState |
|
1441 TDeviceState tmpState = EFinish; |
|
1442 |
|
1443 if(KErrNone != aOperationStatus) |
|
1444 { |
|
1445 // if cancelling, ignore errors |
|
1446 if(ECancelJob == iState && KErrDisconnected == aOperationStatus) |
|
1447 return; |
|
1448 |
|
1449 err = aOperationStatus; |
|
1450 } |
|
1451 else if(EBtStateStopped == aPrinterState) |
|
1452 { |
|
1453 LOG("[CBtPrintingDevice::ManagePrintingState] Printer state stopped."); |
|
1454 if(iPrintEventObserver) |
|
1455 iPrintEventObserver->PrinterStatusEvent(aStateReasons, KErrNone); |
|
1456 |
|
1457 // Mustn't give error here: |
|
1458 // inform via PrinterStatusEvent not at FinishPrinting via PrintJobErrorEvent |
|
1459 err = KErrNone; |
|
1460 } |
|
1461 else |
|
1462 { |
|
1463 switch (aJobState) |
|
1464 { |
|
1465 case EBtStateUnknown: |
|
1466 case EBtStateStopped: |
|
1467 case EBtStateAborted: |
|
1468 err = aStateReasons; |
|
1469 break; |
|
1470 case EBtStateWaiting: |
|
1471 LOG("[CBtPrintingDevice::ManagePrintingState]\t Waiting. Cancel."); |
|
1472 // Don't care if cancel fails: no can do anyway. |
|
1473 CancelPrintJob(); |
|
1474 err = EPbStatusErrorReasonHardwarePrinterBusy; |
|
1475 break; |
|
1476 case EBtStateCompleted: |
|
1477 LOG("[CBtPrintingDevice::ManagePrintingState]\t Completed."); |
|
1478 LOG1("[CBtPrintingDevice::ManagePrintingState]\t iPrinting->JobState: %d", iPrintingJob->JobState()); |
|
1479 |
|
1480 if(CPrintJob::EStatePrinting == iPrintingJob->JobState() || |
|
1481 CPrintJob::EStateSending == iPrintingJob->JobState()) |
|
1482 { |
|
1483 if(iPrintEventObserver) |
|
1484 iPrintEventObserver->PrintJobProgressEvent(EDone, 100, ENoMessage); |
|
1485 } |
|
1486 |
|
1487 else |
|
1488 { |
|
1489 err = EObexSendError; |
|
1490 } |
|
1491 |
|
1492 iPrintingJob->UpdateJobState(CPrintJob::EStateCreated); |
|
1493 break; |
|
1494 case EBtStateCancelled: |
|
1495 LOG("[CBtPrintingDevice::ManagePrintingState]\t Cancelled"); |
|
1496 |
|
1497 // If Bt print is cancelled by Image Print, show error "Check status of Printer" |
|
1498 err = EPbStatusErrorReasonNoReason; |
|
1499 break; |
|
1500 // continue cases |
|
1501 case EBtStatePrinting: |
|
1502 iPrintingJob->UpdateJobState(CPrintJob::EStatePrinting); |
|
1503 percents = UpdateProggress(); |
|
1504 LOG1("[CBtPrintingDevice::ManagePrintingState]\t Printing proggress %d", percents); |
|
1505 |
|
1506 if(iPrintEventObserver) |
|
1507 iPrintEventObserver->PrintJobProgressEvent(EActive, percents, EPrinting); |
|
1508 |
|
1509 tmpState = EGetJobAttributes; |
|
1510 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
1511 break; |
|
1512 case EBtStateSending: |
|
1513 iPrintingJob->UpdateJobState(CPrintJob::EStateSending); |
|
1514 percents = UpdateProggress(); |
|
1515 LOG1("[CBtPrintingDevice::ManagePrintingState]\t Sending proggress %d", percents); |
|
1516 |
|
1517 if(iPrintEventObserver) |
|
1518 iPrintEventObserver->PrintJobProgressEvent(EActive, percents, ECopying); |
|
1519 |
|
1520 tmpState = EJobProgress; |
|
1521 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
1522 return; |
|
1523 default: |
|
1524 tmpState = iState; |
|
1525 break; |
|
1526 } |
|
1527 } |
|
1528 |
|
1529 iPrintError = err; |
|
1530 |
|
1531 TRequestStatus* tmpStatus = &iStatus; |
|
1532 iState = tmpState; |
|
1533 User::RequestComplete(tmpStatus, err); |
|
1534 |
|
1535 SetActive(); |
|
1536 } |
|
1537 |
|
1538 //-------------------------------------------------------------------------------------------- |
|
1539 // |
|
1540 // CBtPrintingDevice::GetJobAttributesL |
|
1541 // |
|
1542 //-------------------------------------------------------------------------------------------- |
|
1543 void CBtPrintingDevice::GetJobAttributesL() |
|
1544 { |
|
1545 LOG1("[CBtPrintingDevice::GetJobAttributesL]\t begin: iState: %d", iState); |
|
1546 |
|
1547 CRsBtDevice* printer = static_cast<CRsBtDevice*>(User::LeaveIfNull( |
|
1548 FindDevice(iPrintingJob->PrinterId()))); |
|
1549 |
|
1550 iPrinterController->GetJobAttributesL(*printer, iPrintingJob->JobId()); |
|
1551 iState = EGetJobAttributes; |
|
1552 |
|
1553 LOG("[CBtPrintingDevice::GetJobAttributesL]\t out"); |
|
1554 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
1555 } |
|
1556 |
|
1557 //-------------------------------------------------------------------------------------------- |
|
1558 // |
|
1559 // CBtPrintingDevice::GetPrinterAttributesL |
|
1560 // |
|
1561 //-------------------------------------------------------------------------------------------- |
|
1562 void CBtPrintingDevice::GetPrinterStateL() |
|
1563 { |
|
1564 LOG1("[CBtPrintingDevice::GetPrinterAttributesL]\t begin: iState: %d", iState); |
|
1565 |
|
1566 CRsBtDevice* printer = static_cast<CRsBtDevice*>(User::LeaveIfNull( |
|
1567 FindDevice(iPrintingJob->PrinterId()))); |
|
1568 |
|
1569 iPrinterController->GetPrinterStateL(*printer); |
|
1570 iState = EGetPrinterState; |
|
1571 |
|
1572 LOG("[CBtPrintingDevice::GetPrinterAttributesL]\t out"); |
|
1573 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
1574 } |
|
1575 |
|
1576 //-------------------------------------------------------------------------------------------- |
|
1577 // |
|
1578 // CBtPrintingDevice::CancelJobL |
|
1579 // |
|
1580 //-------------------------------------------------------------------------------------------- |
|
1581 void CBtPrintingDevice::CancelJobL() |
|
1582 { |
|
1583 LOG("[CBtPrintingDevice::CancelJobL]\t begin"); |
|
1584 |
|
1585 // If not submitted, return |
|
1586 if( !iPrintingJob || |
|
1587 (CPrintJob::EStateSubmitted != iPrintingJob->JobState() && |
|
1588 CPrintJob::EStateSending != iPrintingJob->JobState() && |
|
1589 CPrintJob::EStatePrinting != iPrintingJob->JobState()) ) |
|
1590 User::Leave(KErrInvalidSequence); |
|
1591 |
|
1592 LOG1("[CBtPrintingDevice::CancelJobL]\t begin at iPrintingJob->JobState(): %d", iPrintingJob->JobState()); |
|
1593 |
|
1594 CRsBtDevice* printer = static_cast<CRsBtDevice*>(User::LeaveIfNull( |
|
1595 FindDevice(iPrintingJob->PrinterId()))); |
|
1596 |
|
1597 iPrintingJob->UpdateJobState(CPrintJob::EStateCancel); |
|
1598 |
|
1599 iPrinterController->CancelJobL(*printer, iPrintingJob->JobId()); |
|
1600 iState = ECancelJob; |
|
1601 |
|
1602 TRequestStatus* tmpStatus = &iStatus; |
|
1603 User::RequestComplete(tmpStatus, KErrNone); |
|
1604 SetActive(); |
|
1605 |
|
1606 LOG("[CBtPrintingDevice::CancelJobL]\t out"); |
|
1607 StartTimer(KPrinterResponseTimeout, KPrinterResponseTimeout, TCallBack(HandleTimeout, this) ); |
|
1608 } |
|
1609 |
|
1610 //-------------------------------------------------------------------------------------------- |
|
1611 // |
|
1612 // CBtPrintingDevice::CheckProggress |
|
1613 // |
|
1614 //-------------------------------------------------------------------------------------------- |
|
1615 TInt CBtPrintingDevice::UpdateProggress() |
|
1616 { |
|
1617 TInt percents = iPrinterController->GetPercentSent(); |
|
1618 |
|
1619 if(iProggress != percents && 0 != percents) |
|
1620 { |
|
1621 iProggress = percents; |
|
1622 iPendingCount = 0; |
|
1623 } |
|
1624 |
|
1625 // don't return 100% until the job is reported to be completed. |
|
1626 // that way also the physical printing is included in percents. |
|
1627 if(95 < iProggress) |
|
1628 return 95; |
|
1629 else |
|
1630 return iProggress; |
|
1631 } |
|
1632 |
|
1633 //-------------------------------------------------------------------------------------------- |
|
1634 // |
|
1635 // CBtPrintingDevice::GetLocalBTNameL |
|
1636 // |
|
1637 //-------------------------------------------------------------------------------------------- |
|
1638 void CBtPrintingDevice::GetLocalBTNameL(TDes8& aName) |
|
1639 { |
|
1640 RsUtils::GetLocalBTNameL(aName); |
|
1641 LOG81("[CBtPrintingDevice::GetLocalBTNameL]\t GetLocalBTNameL(%S)", &aName); |
|
1642 } |
|
1643 |
|
1644 //-------------------------------------------------------------------------------------------- |
|
1645 // |
|
1646 // CBtPrintingDevice::OPPSendProgress |
|
1647 // |
|
1648 //-------------------------------------------------------------------------------------------- |
|
1649 void CBtPrintingDevice::OPPSendProgress( TInt aProgress ) |
|
1650 { |
|
1651 if(iPrintEventObserver) |
|
1652 { |
|
1653 // If sendind is finished ( Bytes sent == Job size) it's OK to remove progress bar. |
|
1654 if (aProgress == 100) |
|
1655 { |
|
1656 iPrintEventObserver->PrintJobProgressEvent(EDone, 100, ENoMessage); |
|
1657 } |
|
1658 else |
|
1659 { |
|
1660 // If sending is in progress update progress bar. |
|
1661 iPrintEventObserver->PrintJobProgressEvent(EActive, aProgress, EPrinting); |
|
1662 } |
|
1663 } |
|
1664 } |
|
1665 |
|
1666 // End of File |