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