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 |
|
20 #include "cserverjobguard.h" |
|
21 #include "cimageprintbody.h" |
|
22 #include "clog.h" |
|
23 #include "tmessagewrp2.h" |
|
24 |
|
25 CServerJobGuard* CServerJobGuard::NewL( CImagePrintBody& aEngine ) |
|
26 { |
|
27 CServerJobGuard* self = new ( ELeave ) CServerJobGuard( aEngine ); |
|
28 CleanupStack::PushL( self ); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(); // self |
|
31 return self; |
|
32 } |
|
33 |
|
34 CServerJobGuard::CServerJobGuard( CImagePrintBody& aEngine ) : iEngine( aEngine ), |
|
35 iRequestActive( EFalse ) |
|
36 { |
|
37 } |
|
38 |
|
39 CServerJobGuard::~CServerJobGuard() |
|
40 { |
|
41 LOG("CServerJobGuard::~CServerJobGuard begin"); |
|
42 iImages.ResetAndDestroy(); |
|
43 iImages.Close(); |
|
44 iBuffer.Close(); |
|
45 LOG("CServerJobGuard::~CServerJobGuard end"); |
|
46 } |
|
47 |
|
48 void CServerJobGuard::ConstructL() |
|
49 { |
|
50 } |
|
51 |
|
52 void CServerJobGuard::PrepareL( TMessageWrp2& aMessage ) |
|
53 { |
|
54 LOG("CServerJobGuard::PrepareL begin"); |
|
55 TInt len = aMessage.GetDesLength( 0 ); |
|
56 HBufC* buf = HBufC::NewLC( len ); |
|
57 TPtr ptr( buf->Des() ); |
|
58 aMessage.ReadL( 0, ptr ); |
|
59 iImages.AppendL( buf ); |
|
60 CleanupStack::Pop(); // buf |
|
61 LOG("CServerJobGuard::PrepareL end"); |
|
62 } |
|
63 |
|
64 void CServerJobGuard::Stop() |
|
65 { |
|
66 LOG("CServerJobGuard::Stop begin"); |
|
67 iImages.ResetAndDestroy(); |
|
68 if( iRequestActive ) |
|
69 { |
|
70 LOG("CServerJobGuard::Stop cancelling..."); |
|
71 iMessage->Complete( KErrCancel ); |
|
72 iRequestActive = EFalse; |
|
73 } |
|
74 LOG("CServerJobGuard::Stop end"); |
|
75 } |
|
76 |
|
77 TInt CServerJobGuard::CreateL( TMessageWrp2& aMessage ) |
|
78 { |
|
79 LOG("CServerJobGuard::CreateL begin"); |
|
80 iRequestActive = EFalse; |
|
81 iBuffer.Reset(); |
|
82 TInt printer = aMessage.Int0(); |
|
83 TInt err = iEngine.CreatePrintJobL( printer, iImages, *this ); |
|
84 LOG1("CServerJobGuard::CreateL err: %d", err); |
|
85 if( err ) |
|
86 { |
|
87 iImages.ResetAndDestroy(); |
|
88 } |
|
89 LOG1("CServerJobGuard::CreateL return: %d", err); |
|
90 return err; |
|
91 } |
|
92 |
|
93 void CServerJobGuard::ContinueCreateL( TMessageWrp2& aMessage ) |
|
94 { |
|
95 LOG("CServerJobGuard::ContinueCreateL begin"); |
|
96 if( iMessage ) iMessage->SetDisposable( ETrue ); |
|
97 iMessage = &aMessage; |
|
98 iRequestActive = ETrue; |
|
99 if( iBuffer.Count() ) |
|
100 { |
|
101 LOG("CServerJobGuard::ContinueCreateL before ProcessL"); |
|
102 Process(); |
|
103 LOG("CServerJobGuard::ContinueCreateL after ProcessL"); |
|
104 } |
|
105 LOG("CServerJobGuard::ContinueCreateL end"); |
|
106 } |
|
107 |
|
108 void CServerJobGuard::PrintJobProgressEvent(TInt aStatus, TInt aPercentCompletion, TInt aJobStateCode) |
|
109 { |
|
110 LOG("CServerJobGuard::PrintJobProgressEvent begin"); |
|
111 LOG1("CServerJobGuard::PrintJobProgressEvent aStatus: %d", aStatus); |
|
112 LOG1("CServerJobGuard::PrintJobProgressEvent aPercentCompletion: %d", aPercentCompletion); |
|
113 LOG1("CServerJobGuard::PrintJobProgressEvent aJobStateCode: %d", aJobStateCode); |
|
114 TJobGuardData data; |
|
115 data.iCb = TJobGuardData::EProgressEventCb; |
|
116 data.iStatus = aStatus; |
|
117 data.iPercentCompletion = aPercentCompletion; |
|
118 data.iJobStateCode = aJobStateCode; |
|
119 TRAPD( err, DoPreProcessL( data ) ); |
|
120 LOG1("CServerJobGuard::PrintJobProgressEvent DoPreProcessL's TRAP err: %d", err); |
|
121 Process( err ); |
|
122 LOG("CServerJobGuard::PrintJobProgressEvent end"); |
|
123 } |
|
124 |
|
125 void CServerJobGuard::PrintJobErrorEvent(TInt aError, TInt aErrorStringCode) |
|
126 { |
|
127 LOG("CServerJobGuard::PrintJobErrorEvent begin"); |
|
128 LOG1("CServerJobGuard::PrintJobErrorEvent aError: %d", aError); |
|
129 LOG1("CServerJobGuard::PrintJobErrorEvent aErrorStringCode: %d", aErrorStringCode); |
|
130 TJobGuardData data; |
|
131 data.iCb = TJobGuardData::EErrorEventCb; |
|
132 data.iError = aError; |
|
133 data.iErrorStringCode = aErrorStringCode; |
|
134 TRAPD( err, DoPreProcessL( data ) ); |
|
135 LOG1("CServerJobGuard::PrintJobErrorEvent DoPreProcessL's TRAP err: %d", err); |
|
136 Process( err ); |
|
137 LOG("CServerJobGuard::PrintJobErrorEvent end"); |
|
138 } |
|
139 |
|
140 void CServerJobGuard::PrinterStatusEvent(TInt aError, TInt aErrorStringCode) |
|
141 { |
|
142 LOG("CServerJobGuard::PrinterStatusEvent begin"); |
|
143 LOG1("CServerJobGuard::PrinterStatusEvent aError: %d", aError); |
|
144 LOG1("CServerJobGuard::PrinterStatusEvent aErrorStringCode: %d", aErrorStringCode); |
|
145 TJobGuardData data; |
|
146 data.iCb = TJobGuardData::EStatusEventCb; |
|
147 data.iError = aError; |
|
148 data.iErrorStringCode = aErrorStringCode; |
|
149 TRAPD( err, DoPreProcessL( data ) ); |
|
150 LOG1("CServerJobGuard::PrinterStatusEvent DoPreProcessL's TRAP err: %d", err); |
|
151 Process( err ); |
|
152 LOG("CServerJobGuard::PrinterStatusEvent end"); |
|
153 } |
|
154 |
|
155 void CServerJobGuard::PreviewImageEvent(TInt aFsBitmapHandle) |
|
156 { |
|
157 LOG("CServerJobGuard::PreviewImageEvent begin"); |
|
158 LOG1("CServerJobGuard::PreviewImageEvent aFsBitmapHandle: %d", aFsBitmapHandle); |
|
159 TJobGuardData data; |
|
160 data.iCb = TJobGuardData::EImageEventCb; |
|
161 data.iFsBitmapHandle = aFsBitmapHandle; |
|
162 TRAPD( err, DoPreProcessL( data ) ); |
|
163 LOG1("CServerJobGuard::PreviewImageEvent DoPreProcessL's TRAP err: %d", err); |
|
164 Process( err ); |
|
165 LOG("CServerJobGuard::PreviewImageEvent end"); |
|
166 } |
|
167 |
|
168 void CServerJobGuard::DoPreProcessL( const TJobGuardData& aData ) |
|
169 { |
|
170 LOG("CServerJobGuard::DoPreProcessL begin"); |
|
171 User::LeaveIfError( iBuffer.Append( aData ) ); |
|
172 LOG("CServerJobGuard::DoPreProcessL end"); |
|
173 } |
|
174 |
|
175 void CServerJobGuard::DoProcessL() |
|
176 { |
|
177 LOG("CServerJobGuard::ProcessL begin"); |
|
178 if( iBuffer.Count() && iRequestActive ) |
|
179 { |
|
180 LOG("CServerJobGuard::DoProcessL step 1"); |
|
181 TPtr8 ptr(reinterpret_cast<TUint8*>(&(iBuffer[0])), sizeof(iBuffer[0]), sizeof(iBuffer[0])); |
|
182 LOG("CServerJobGuard::DoProcessL step 2"); |
|
183 iMessage->WriteL( 0, ptr ); |
|
184 LOG("CServerJobGuard::DoProcessL step 3"); |
|
185 iMessage->Complete( KErrNone ); |
|
186 LOG("CServerJobGuard::DoProcessL step 4"); |
|
187 iRequestActive = EFalse; |
|
188 LOG("CServerJobGuard::DoProcessL step 5"); |
|
189 iBuffer.Remove( 0 ); |
|
190 LOG("CServerJobGuard::DoProcessL step 6"); |
|
191 } |
|
192 LOG("CServerJobGuard::ProcessL end"); |
|
193 } |
|
194 |
|
195 void CServerJobGuard::Process( TInt aErr ) |
|
196 { |
|
197 LOG("CServerJobGuard::Process begin"); |
|
198 if( aErr ) |
|
199 { |
|
200 LOG1("CServerJobGuard::Process aErr: %d", aErr); |
|
201 iMessage->Complete( aErr ); |
|
202 iRequestActive = EFalse; |
|
203 } |
|
204 else |
|
205 { |
|
206 LOG("CServerJobGuard::Process calling DoProcessL"); |
|
207 TRAPD( err, DoProcessL() ); |
|
208 LOG1("CServerJobGuard::Process DoProcessL's TRAP err: %d", err); |
|
209 if( err ) |
|
210 { |
|
211 iMessage->Complete( err ); |
|
212 iRequestActive = EFalse; |
|
213 } |
|
214 } |
|
215 LOG("CServerJobGuard::Process end"); |
|
216 } |
|
217 |
|
218 |
|
219 |
|
220 // DEPRECATED |
|
221 |
|
222 void CServerJobGuard::ShowMessageL( TInt /*aMsgLine1Code*/, TInt /*aMsgLine2Code*/ ) |
|
223 { |
|
224 } |
|
225 |
|
226 TBool CServerJobGuard::AskYesNoQuestionL( TInt /*aMsgLine1Code*/, TInt /*aMsgLine2Code*/ ) |
|
227 { |
|
228 return EFalse; |
|
229 } |
|
230 |
|
231 const TDesC& CServerJobGuard::AskForInputL( TInt /*aMsgLine1Code*/, TInt /*aMsgLine2Code*/ ) |
|
232 { |
|
233 return KNullDesC; |
|
234 } |
|
235 |
|
236 // End of File |
|