|
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 #include "cprinteventcatcher.h" |
|
20 #include "crealfactory.h" |
|
21 #include "mprintpreviewobserver.h" |
|
22 #include "mprintjobstatus.h" |
|
23 #include "cprintjobmanager.h" |
|
24 #include "clog.h" |
|
25 |
|
26 // CONSTRUCTION |
|
27 CPrintEventCatcher* CPrintEventCatcher::NewL( |
|
28 CIFFactory* aFactory, |
|
29 CImagePrintEngine* aEngine ) |
|
30 { |
|
31 CPrintEventCatcher* self = CPrintEventCatcher::NewLC( aFactory, aEngine ); |
|
32 CleanupStack::Pop(); // self |
|
33 |
|
34 return self; |
|
35 } |
|
36 |
|
37 CPrintEventCatcher* CPrintEventCatcher::NewLC( |
|
38 CIFFactory* aFactory, |
|
39 CImagePrintEngine* aEngine ) |
|
40 { |
|
41 CPrintEventCatcher* self = |
|
42 new ( ELeave ) CPrintEventCatcher( aFactory, aEngine ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 |
|
46 return self; |
|
47 } |
|
48 |
|
49 // Constructor |
|
50 CPrintEventCatcher::CPrintEventCatcher( |
|
51 CIFFactory* aFactory, |
|
52 CImagePrintEngine* aEngine ) : |
|
53 iFactory( aFactory ), |
|
54 iEngine( aEngine ) |
|
55 { |
|
56 } |
|
57 |
|
58 // Destructor |
|
59 CPrintEventCatcher::~CPrintEventCatcher() |
|
60 { |
|
61 iObservers.Reset(); |
|
62 } |
|
63 |
|
64 // 2nd phase constructor |
|
65 void CPrintEventCatcher::ConstructL() |
|
66 { |
|
67 } |
|
68 |
|
69 // Print progress event |
|
70 void CPrintEventCatcher::PrintJobProgressEvent( |
|
71 TInt aStatus, |
|
72 TInt aPercentCompletion, |
|
73 TInt aJobStateCode ) |
|
74 { |
|
75 TInt obsCount = iObservers.Count(); |
|
76 for( TInt i=0; i<obsCount; i++ ) |
|
77 { |
|
78 iObservers[i]->PrintJobProgress( aStatus, aPercentCompletion, |
|
79 aJobStateCode ); |
|
80 } |
|
81 } |
|
82 |
|
83 // Print job error event |
|
84 void CPrintEventCatcher::PrintJobErrorEvent( |
|
85 TInt aError, |
|
86 TInt aErrorStringCode ) |
|
87 { |
|
88 LOG2("CPrintEventCatcher::PrintJobErrorEvent: aError: %d, aErrorStringCode: %d ", |
|
89 aError, aErrorStringCode ); |
|
90 TInt obsCount = iObservers.Count(); |
|
91 for( TInt i=0; i<obsCount; i++ ) |
|
92 { |
|
93 iObservers[i]->PrintJobError( aError, aErrorStringCode ); |
|
94 } |
|
95 } |
|
96 |
|
97 // Print job status event ("minor" error) |
|
98 void CPrintEventCatcher::PrinterStatusEvent( |
|
99 TInt aError, |
|
100 TInt aErrorStringCode ) |
|
101 { |
|
102 LOG2("CPrintEventCatcher::PrinterStatusEvent: aError: %d, aErrorStringCode: %d ", |
|
103 aError, aErrorStringCode ); |
|
104 TInt obsCount = iObservers.Count(); |
|
105 for( TInt i=0; i<obsCount; i++ ) |
|
106 { |
|
107 iObservers[i]->PrinterStatus( aError, aErrorStringCode ); |
|
108 } |
|
109 } |
|
110 |
|
111 // Receives preview events from the image print server |
|
112 void CPrintEventCatcher::PreviewImageEvent( |
|
113 TInt /*aFsBitmapHandle*/ ) |
|
114 { |
|
115 // Should not be called from engine anymore |
|
116 } |
|
117 |
|
118 // Set preview observer |
|
119 void CPrintEventCatcher::SetPreviewObserver( |
|
120 MPrintPreviewObserver* aObserver ) |
|
121 { |
|
122 iPreviewObserver = aObserver; |
|
123 } |
|
124 |
|
125 void CPrintEventCatcher::RegisterObserver( MPrintJobStatus* aObserver ) |
|
126 { |
|
127 iObservers.Append( aObserver ); |
|
128 } |
|
129 |
|
130 void CPrintEventCatcher::UnRegisterObserver( MPrintJobStatus* aObserver ) |
|
131 { |
|
132 TInt observerPosition = iObservers.Find( aObserver ); |
|
133 if( observerPosition != KErrNotFound ) |
|
134 { |
|
135 iObservers.Remove( observerPosition ); |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 // GOING TO GET REMOVED |
|
141 void CPrintEventCatcher::ShowMessageL( |
|
142 TInt /*aMsgLine1Code*/, |
|
143 TInt /*aMsgLine2Code*/ ) |
|
144 { |
|
145 } |
|
146 |
|
147 // GOING TO GET REMOVED |
|
148 TBool CPrintEventCatcher::AskYesNoQuestionL( |
|
149 TInt /*aMsgLine1Code*/, |
|
150 TInt /*aMsgLine2Code*/ ) |
|
151 { |
|
152 return EFalse; |
|
153 } |
|
154 |
|
155 // GOING TO GET REMOVED |
|
156 const TDesC& CPrintEventCatcher::AskForInputL( |
|
157 TInt /*aMsgLine1Code*/, |
|
158 TInt /*aMsgLine2Code*/ ) |
|
159 { |
|
160 return KNullDesC; |
|
161 } |
|
162 |
|
163 // End of File |