29
|
1 |
/*
|
|
2 |
* Copyright (c) 2006, 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: This class creates and parses dps operations.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <pathinfo.h>
|
|
21 |
#include <s32file.h>
|
|
22 |
#include "dpstransaction.h"
|
|
23 |
#include "dpsscriptsender.h"
|
|
24 |
#include "dpsdefs.h"
|
|
25 |
#include "dpsxmlparser.h"
|
|
26 |
#include "dpsxmlgenerator.h"
|
|
27 |
#include "dpsconst.h"
|
|
28 |
#include "dpsfile.h"
|
|
29 |
#include "dpsstatemachine.h"
|
|
30 |
#include "dpsscriptreceiver.h"
|
|
31 |
#include "pictbridge.h"
|
|
32 |
#include <xml/parser.h>
|
|
33 |
#include "dpsparam.h"
|
|
34 |
#include "dpsoperation.h"
|
|
35 |
#include "dpsxmlstring.h"
|
49
|
36 |
#include "mtpdebug.h"
|
|
37 |
#include "OstTraceDefinitions.h"
|
|
38 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
39 |
#include "dpstransactionTraces.h"
|
|
40 |
#endif
|
29
|
41 |
|
|
42 |
|
|
43 |
const TInt KPathLength = 3;
|
|
44 |
const TInt KPercentagePosition = 3;
|
|
45 |
const TInt KPercentage = 100;
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
CDpsTransaction* CDpsTransaction::NewL(CDpsStateMachine* aOperator)
|
|
51 |
{
|
|
52 |
CDpsTransaction* self = new(ELeave) CDpsTransaction(aOperator);
|
|
53 |
CleanupStack::PushL(self);
|
|
54 |
self->ConstructL();
|
|
55 |
CleanupStack::Pop();
|
|
56 |
return self;
|
|
57 |
}
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
CDpsTransaction::CDpsTransaction(CDpsStateMachine* aOperator) :
|
|
64 |
iOperator(aOperator), iReply(EFalse)
|
|
65 |
{
|
49
|
66 |
OstTraceFunctionEntry0( CDPSTRANSACTION_CDPSTRANSACTION_CONS_ENTRY );
|
|
67 |
OstTraceFunctionExit0( CDPSTRANSACTION_CDPSTRANSACTION_CONS_EXIT );
|
29
|
68 |
}
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
void CDpsTransaction::ConstructL()
|
|
75 |
{
|
49
|
76 |
OstTraceFunctionEntry0( CDPSTRANSACTION_CONSTRUCTL_ENTRY );
|
29
|
77 |
iFile = CDpsFile::NewL();
|
|
78 |
iXmlGen = CDpsXmlGenerator::NewL(iOperator->DpsEngine());
|
|
79 |
iXmlPar = CDpsXmlParser::NewL(iOperator->DpsEngine());
|
49
|
80 |
OstTraceFunctionExit0( CDPSTRANSACTION_CONSTRUCTL_EXIT );
|
29
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
CDpsTransaction::~CDpsTransaction()
|
|
88 |
{
|
49
|
89 |
OstTraceFunctionEntry0( DUP1_CDPSTRANSACTION_CDPSTRANSACTION_DES_ENTRY );
|
29
|
90 |
delete iXmlPar;
|
|
91 |
iXmlPar = NULL;
|
|
92 |
|
|
93 |
delete iXmlGen;
|
|
94 |
iXmlGen = NULL;
|
|
95 |
|
|
96 |
delete iFile;
|
|
97 |
iFile = NULL;
|
49
|
98 |
|
|
99 |
OstTraceFunctionExit0( DUP1_CDPSTRANSACTION_CDPSTRANSACTION_DES_EXIT );
|
29
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CDpsTransaction::CreateRequestL(TMDpsOperation* aOperation)
|
|
107 |
{
|
49
|
108 |
OstTraceFunctionEntry0( CDPSTRANSACTION_CREATEREQUESTL_ENTRY );
|
|
109 |
OstTrace1( TRACE_NORMAL, CDPSTRANSACTION_CREATEREQUESTL, " the request is %d", aOperation->iOperation );
|
29
|
110 |
TDpsArgArray args;
|
|
111 |
TDpsEleArray elements;
|
|
112 |
TDpsAttribute attrib = 0;
|
|
113 |
CleanupClosePushL(args);
|
|
114 |
CleanupClosePushL(elements);
|
|
115 |
RFileWriteStream writer;
|
|
116 |
writer.PushL();
|
|
117 |
TFileName defaultPath = iOperator->DpsEngine()->DpsFolder();
|
|
118 |
defaultPath.Append(KDpsDeviceRequestFileName);
|
49
|
119 |
LEAVEIFERROR(writer.Replace(iFile->FileSession(), defaultPath, EFileWrite),
|
|
120 |
OstTraceExt2( TRACE_ERROR, DUP2_CDPSTRANSACTION_CREATEREQUESTL,
|
|
121 |
"Creates %S for stream failed ! error code %d", defaultPath, munged_err ));
|
|
122 |
OstTrace0( TRACE_NORMAL, DUP1_CDPSTRANSACTION_CREATEREQUESTL, "*** file created " );
|
|
123 |
LEAVEIFERROR(aOperation->FillReqArgs(args, elements, attrib, this),
|
|
124 |
OstTrace1( TRACE_ERROR, DUP3_CDPSTRANSACTION_CREATEREQUESTL, "FillReqArgs failed! error code %d", munged_err ));
|
29
|
125 |
aOperation->CreateReqScriptL(args, elements, attrib, writer, this);
|
|
126 |
writer.CommitL();
|
|
127 |
writer.Pop();
|
|
128 |
writer.Release();
|
49
|
129 |
LEAVEIFERROR(iOperator->ScriptSender()->SendScript(EFalse),
|
|
130 |
OstTrace1( TRACE_ERROR, DUP4_CDPSTRANSACTION_CREATEREQUESTL, "SendScript failed! error code %d", munged_err ));
|
29
|
131 |
CleanupStack::PopAndDestroy(&elements);
|
|
132 |
CleanupStack::PopAndDestroy(&args);
|
49
|
133 |
OstTraceFunctionExit0( CDPSTRANSACTION_CREATEREQUESTL_EXIT );
|
29
|
134 |
}
|
|
135 |
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
void CDpsTransaction::Filter(TDes8& aScript)
|
|
141 |
{
|
49
|
142 |
OstTraceFunctionEntry0( CDPSTRANSACTION_FILTER_ENTRY );
|
29
|
143 |
TInt size = aScript.Size();
|
49
|
144 |
OstTrace1( TRACE_NORMAL, CDPSTRANSACTION_FILTER, "size %d", size);
|
|
145 |
|
29
|
146 |
for (TInt i = 0; i < size; )
|
|
147 |
{
|
|
148 |
// removes any unprintalbe char between two XML attributes, e.g.
|
|
149 |
// between > and <
|
|
150 |
if (aScript[i] >= KSOH && aScript[i] <= KSpace && aScript[i -1] == '>')
|
|
151 |
{
|
|
152 |
aScript.Delete(i, 1);
|
|
153 |
size--;
|
|
154 |
}
|
|
155 |
else
|
|
156 |
{
|
|
157 |
i++;
|
|
158 |
}
|
|
159 |
}
|
49
|
160 |
OstTrace1( TRACE_NORMAL, DUP1_CDPSTRANSACTION_FILTER, "size %d", size);
|
|
161 |
OstTraceFunctionExit0( CDPSTRANSACTION_FILTER_EXIT );
|
29
|
162 |
}
|
|
163 |
|
|
164 |
// ---------------------------------------------------------------------------
|
|
165 |
//
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CDpsTransaction::ParseScriptL(TBool aReply)
|
|
169 |
{
|
49
|
170 |
OstTraceFunctionEntry0( CDPSTRANSACTION_PARSESCRIPTL_ENTRY );
|
29
|
171 |
iReply = aReply;
|
|
172 |
TInt size;
|
|
173 |
iFile->FileSizeL(iOperator->ScriptReceiver()->FileNameAndPath(), size);
|
|
174 |
HBufC8* script = HBufC8::NewLC(size);
|
|
175 |
TPtr8 ptr_script = script->Des();
|
|
176 |
iFile->GetContentL(iOperator->ScriptReceiver()->FileNameAndPath(),
|
|
177 |
ptr_script);
|
|
178 |
Filter(ptr_script);
|
|
179 |
iXmlPar->Reset();
|
|
180 |
CParser* parser = CParser::NewLC(KDpsXmlMimeType, *iXmlPar);
|
|
181 |
Xml::ParseL(*parser, ptr_script);
|
|
182 |
TDpsArgArray args; iXmlPar->GetParameters(args);
|
|
183 |
|
|
184 |
#ifdef _DEBUG
|
|
185 |
//print what we get now
|
|
186 |
TBuf<KMaxArgLen> print;
|
|
187 |
for (TInt i = 0; i < args.Count(); i++)
|
|
188 |
{
|
|
189 |
print.Copy(args[i].iContent);
|
49
|
190 |
OstTraceExt2( TRACE_NORMAL, CDPSTRANSACTION_PARSESCRIPTL, "element %d content %S", args[i].iElement, print );
|
29
|
191 |
}
|
|
192 |
#endif
|
|
193 |
|
|
194 |
if (aReply)
|
|
195 |
{
|
|
196 |
TMDpsOperation* op = iOperator->MOperation();
|
49
|
197 |
LEAVEIFERROR(op->FillRepArgs(args, this),
|
|
198 |
OstTrace1( TRACE_ERROR, DUP1_CDPSTRANSACTION_PARSESCRIPTL,
|
|
199 |
"FillRepArgs failed! error code %d", munged_err ));
|
29
|
200 |
iXmlPar->SetOperationResult(op->iResult);
|
|
201 |
}
|
|
202 |
else
|
|
203 |
{
|
|
204 |
TDpsResult result;
|
|
205 |
result.iMajorCode = EDpsResultOk;
|
|
206 |
result.iMinorCode = EDpsResultNone;
|
|
207 |
if (iXmlPar->IsEvent())
|
|
208 |
{
|
|
209 |
TDpsEvent event = iXmlPar->Event();
|
|
210 |
iOperator->SetEvent(event);
|
|
211 |
if (event == EDpsEvtNotifyJobStatus)
|
|
212 |
{
|
49
|
213 |
LEAVEIFERROR(iOperator->DpsEngine()->Event()->
|
|
214 |
iJobEvent.FillRepArgs(args, this),
|
|
215 |
OstTrace1( TRACE_ERROR, DUP2_CDPSTRANSACTION_PARSESCRIPTL,
|
|
216 |
"iJobEvent.FillRepArgs failed! error code %d", munged_err ));
|
29
|
217 |
}
|
|
218 |
else
|
|
219 |
{
|
49
|
220 |
LEAVEIFERROR(iOperator->DpsEngine()->Event()->
|
|
221 |
iPrinterEvent.FillRepArgs(args, this),
|
|
222 |
OstTrace1( TRACE_ERROR, DUP3_CDPSTRANSACTION_PARSESCRIPTL,
|
|
223 |
"iPrinterEvent.FillRepArgs failed! error code %d", munged_err ));
|
29
|
224 |
}
|
|
225 |
CreateEventReplyL(event, result);
|
|
226 |
}
|
|
227 |
else
|
|
228 |
{
|
|
229 |
// the request from the host is only this one:
|
|
230 |
// GetFileID and used by DPOF printing
|
|
231 |
TDpsOperation ope = iXmlPar->Operation();
|
|
232 |
iOperator->SetOperation(ope);
|
|
233 |
if (iOperator->Operation() != EDpsOpGetFileID)
|
|
234 |
{
|
49
|
235 |
OstTrace1( TRACE_ERROR, DUP4_CDPSTRANSACTION_PARSESCRIPTL,
|
|
236 |
"The operation %d doesn't equal to EDpsOpGetFileID", iOperator->Operation());
|
29
|
237 |
User::Leave(KErrNotSupported);
|
|
238 |
}
|
|
239 |
CreateRequestReplyL(args, result);
|
|
240 |
}
|
|
241 |
}
|
|
242 |
CleanupStack::PopAndDestroy(parser);
|
|
243 |
CleanupStack::PopAndDestroy(script);
|
49
|
244 |
OstTraceFunctionExit0( CDPSTRANSACTION_PARSESCRIPTL_EXIT );
|
29
|
245 |
}
|
|
246 |
|
|
247 |
// ---------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
void CDpsTransaction::HandleHostRequestError(TInt aErr)
|
|
252 |
{
|
49
|
253 |
OstTraceFunctionEntry0( CDPSTRANSACTION_HANDLEHOSTREQUESTERROR_ENTRY );
|
|
254 |
OstTrace1( TRACE_NORMAL, CDPSTRANSACTION_HANDLEHOSTREQUESTERROR, "Error %d", aErr );
|
29
|
255 |
TDpsResult result;
|
|
256 |
// here we need to map the aErr to Dps standard error
|
|
257 |
switch (aErr)
|
|
258 |
{
|
|
259 |
case KErrNotSupported:
|
|
260 |
result.iMajorCode = EDpsResultNotRecognized;
|
|
261 |
result.iMinorCode = EDpsResultNone;
|
|
262 |
break;
|
|
263 |
|
|
264 |
case KErrArgument:
|
|
265 |
result.iMajorCode = EDpsResultNotSupported;
|
|
266 |
result.iMinorCode = EDpsResultillegalParam;
|
|
267 |
break;
|
|
268 |
|
|
269 |
default:
|
49
|
270 |
OstTrace0( TRACE_NORMAL, DUP1_CDPSTRANSACTION_HANDLEHOSTREQUESTERROR, "unknown err" );
|
|
271 |
OstTraceFunctionExit0( CDPSTRANSACTION_HANDLEHOSTREQUESTERROR_EXIT );
|
29
|
272 |
return;
|
|
273 |
}
|
|
274 |
TRAP_IGNORE(CreateEventReplyL(iXmlPar->Event(), result));
|
49
|
275 |
|
|
276 |
OstTraceFunctionExit0( DUP1_CDPSTRANSACTION_HANDLEHOSTREQUESTERROR_EXIT );
|
29
|
277 |
return;
|
|
278 |
}
|
|
279 |
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
TInt CDpsTransaction::ConvertVersion(TLex8& aParser, TDpsVersion& aVersion)
|
|
285 |
{
|
|
286 |
aParser.Mark();
|
|
287 |
while (!aParser.Eos())
|
|
288 |
{
|
|
289 |
TChar c = aParser.Peek();
|
|
290 |
if (!c.IsDigit())
|
|
291 |
{
|
|
292 |
break;
|
|
293 |
}
|
|
294 |
aParser.Inc();
|
|
295 |
}
|
|
296 |
TPtrC8 token = aParser.MarkedToken();
|
|
297 |
TLex8 converter(token);
|
|
298 |
TInt error = converter.Val(aVersion.iMajor);
|
|
299 |
|
|
300 |
if (error != KErrNone)
|
|
301 |
{
|
49
|
302 |
OstTrace0( TRACE_ERROR, CDPSTRANSACTION_CONVERTVERSION, "convert error 1" );
|
29
|
303 |
return error;
|
|
304 |
}
|
49
|
305 |
OstTrace1( TRACE_NORMAL, DUP1_CDPSTRANSACTION_CONVERTVERSION, "verion major %d", aVersion.iMajor );
|
29
|
306 |
aParser.Inc();
|
|
307 |
TPtrC8 tokenDe = aParser.Remainder();
|
|
308 |
converter.Assign(tokenDe);
|
|
309 |
error = converter.Val(aVersion.iMinor);
|
|
310 |
if (error != KErrNone)
|
|
311 |
{
|
49
|
312 |
OstTrace0( TRACE_ERROR, DUP2_CDPSTRANSACTION_CONVERTVERSION, "convert error 2" );
|
29
|
313 |
return error;
|
|
314 |
}
|
49
|
315 |
OstTrace1( TRACE_NORMAL, DUP3_CDPSTRANSACTION_CONVERTVERSION, "verion minor %d", aVersion.iMinor );
|
29
|
316 |
return KErrNone;
|
|
317 |
}
|
|
318 |
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
// ---------------------------------------------------------------------------
|
|
322 |
//
|
|
323 |
TInt CDpsTransaction::ParsePercentage(const TDes8& aPer)
|
|
324 |
{
|
|
325 |
TLex8 parser(aPer);
|
|
326 |
parser.Mark();
|
|
327 |
parser.Inc(KPercentagePosition);
|
|
328 |
TPtrC8 digital = parser.MarkedToken();
|
|
329 |
TLex8 converter(digital);
|
|
330 |
TInt num1;
|
|
331 |
TInt error = converter.Val(num1);
|
|
332 |
if (error != KErrNone)
|
|
333 |
{
|
|
334 |
return error;
|
|
335 |
}
|
|
336 |
|
|
337 |
parser.Inc(1);
|
|
338 |
parser.Mark();
|
|
339 |
parser.Inc(KPercentagePosition);
|
|
340 |
digital.Set(parser.MarkedToken());
|
|
341 |
converter.Assign(digital);
|
|
342 |
TInt num2;
|
|
343 |
error = converter.Val(num2);
|
|
344 |
if (error != KErrNone)
|
|
345 |
{
|
|
346 |
return error;
|
|
347 |
}
|
|
348 |
|
|
349 |
TReal per = (TReal)num1 / (TReal)num2 * KPercentage;
|
|
350 |
return (TInt)per;
|
|
351 |
}
|
|
352 |
|
|
353 |
// ---------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
// ---------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
void CDpsTransaction::CreateEventReplyL(TDpsEvent aEvent,
|
|
358 |
const TDpsResult& aResult)
|
|
359 |
|
|
360 |
{
|
49
|
361 |
OstTraceFunctionEntry0( CDPSTRANSACTION_CREATEEVENTREPLYL_ENTRY );
|
|
362 |
OstTrace1( TRACE_NORMAL, CDPSTRANSACTION_CREATEEVENTREPLYL, "the operation reply is %d", iOperator->Operation() );
|
|
363 |
OstTrace1( TRACE_NORMAL, DUP1_CDPSTRANSACTION_CREATEEVENTREPLYL, "the event reply is %d", iOperator->Event());
|
|
364 |
|
29
|
365 |
RFileWriteStream writer;
|
|
366 |
writer.PushL();
|
|
367 |
TFileName defaultPath = iOperator->DpsEngine()->DpsFolder();
|
|
368 |
defaultPath.Append(KDpsDeviceResponseFileName);
|
49
|
369 |
LEAVEIFERROR(writer.Replace(iFile->FileSession(), defaultPath, EFileWrite),
|
|
370 |
OstTraceExt2( TRACE_ERROR, DUP3_CDPSTRANSACTION_CREATEEVENTREPLYL,
|
|
371 |
"Creates %S for stream failed ! error code %d", defaultPath, munged_err ));
|
|
372 |
OstTrace0( TRACE_NORMAL, DUP2_CDPSTRANSACTION_CREATEEVENTREPLYL, "*** file created " );
|
|
373 |
|
29
|
374 |
iXmlGen->CreateResultScriptL(aEvent, writer, aResult);
|
|
375 |
writer.CommitL();
|
|
376 |
writer.Pop();
|
|
377 |
writer.Release();
|
49
|
378 |
LEAVEIFERROR(iOperator->ScriptSender()->SendScript(ETrue),
|
|
379 |
OstTrace1( TRACE_ERROR, DUP4_CDPSTRANSACTION_CREATEEVENTREPLYL,
|
|
380 |
"SendScript failed! error code %d", munged_err ));
|
|
381 |
OstTraceFunctionExit0( CDPSTRANSACTION_CREATEEVENTREPLYL_EXIT );
|
29
|
382 |
}
|
|
383 |
|
|
384 |
// ---------------------------------------------------------------------------
|
|
385 |
//
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
void CDpsTransaction::CreateRequestReplyL(const TDpsArgArray& aArgs,
|
|
389 |
const TDpsResult& aResult)
|
|
390 |
{
|
49
|
391 |
OstTraceFunctionEntry0( CDPSTRANSACTION_CREATEREQUESTREPLYL_ENTRY );
|
29
|
392 |
TInt count = aArgs.Count();
|
|
393 |
TInt basePathId;
|
|
394 |
TBuf8<KMaxArgLen> filePath;
|
|
395 |
TLex8 converter;
|
|
396 |
|
|
397 |
for (TInt i = 0; i < count; i++)
|
|
398 |
{
|
|
399 |
switch (aArgs[i].iElement)
|
|
400 |
{
|
|
401 |
case EDpsArgBasePathID:
|
|
402 |
converter.Assign(aArgs[i].iContent);
|
49
|
403 |
LEAVEIFERROR(converter.Val(basePathId),
|
|
404 |
OstTrace1( TRACE_ERROR, DUP2_CDPSTRANSACTION_CREATEREQUESTREPLYL,
|
|
405 |
"Parses the string failed! error code %d", munged_err ));
|
29
|
406 |
break;
|
|
407 |
|
|
408 |
case EDpsArgFilePath:
|
|
409 |
filePath.Copy(aArgs[i].iContent);
|
|
410 |
break;
|
|
411 |
|
|
412 |
default:
|
49
|
413 |
OstTrace0( TRACE_ERROR, CDPSTRANSACTION_CREATEREQUESTREPLYL, "***wrong args" );
|
29
|
414 |
User::Leave(KErrArgument);
|
|
415 |
break;
|
|
416 |
}
|
|
417 |
TUint32 fileId;
|
|
418 |
|
|
419 |
SubstitutePath(filePath);
|
|
420 |
TBuf<KMaxArgLen> file;
|
|
421 |
file.Copy(filePath);
|
49
|
422 |
(iOperator->DpsEngine()->
|
29
|
423 |
Ptp().GetObjectHandleByName(file, fileId));
|
|
424 |
TDpsArg arg;
|
|
425 |
arg.iElement = EDpsArgFileID;
|
|
426 |
arg.iContent.AppendNumFixedWidth(fileId, EHex, KFullWordWidth);
|
|
427 |
RFileWriteStream writer;
|
|
428 |
writer.PushL();
|
|
429 |
TFileName defaultPath = iOperator->DpsEngine()->DpsFolder();
|
|
430 |
defaultPath.Append(KDpsDeviceResponseFileName);
|
49
|
431 |
(writer.Replace(iFile->FileSession(), defaultPath,
|
29
|
432 |
EFileWrite));
|
49
|
433 |
OstTrace0( TRACE_NORMAL, DUP1_CDPSTRANSACTION_CREATEREQUESTREPLYL, "*** file created " );
|
29
|
434 |
iXmlGen->CreateReplyScriptL(EDpsOpGetFileID, writer, aResult, arg);
|
49
|
435 |
(iOperator->ScriptSender()->SendScript(ETrue));
|
29
|
436 |
writer.CommitL();
|
|
437 |
writer.Pop();
|
|
438 |
writer.Release();
|
|
439 |
}
|
49
|
440 |
OstTraceFunctionExit0( CDPSTRANSACTION_CREATEREQUESTREPLYL_EXIT );
|
29
|
441 |
}
|
|
442 |
|
|
443 |
// ---------------------------------------------------------------------------
|
|
444 |
// The aPath is not the full file path, at least the
|
|
445 |
// driver letter is not included. The structure of the DPOF filePath is
|
|
446 |
// ../path/childpath/imagePrinted.jpg and GetObjectHandleByName
|
|
447 |
// requires the full path file as e:\images\image1.jpg
|
|
448 |
// the basePathId is not useful because it is always the fileId
|
|
449 |
// of AUTPRINT.MRK. But since DPOF is always used for the removable
|
|
450 |
// media, we assume that images are only stored in removable media.
|
|
451 |
// If the assumption is true (must be true), we need here first to
|
|
452 |
// get the removable drive (hopefully only one). Then substitute
|
|
453 |
// the / by the \ in the filePath. Finally, insert the removable drive
|
|
454 |
// letter and : at the beginning of the filePath. The new full path
|
|
455 |
// file can be used by GetObjectHandleByName
|
|
456 |
// ---------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
void CDpsTransaction::SubstitutePath(TDes8& aPath)
|
|
459 |
{
|
49
|
460 |
OstTraceFunctionEntry0( CDPSTRANSACTION_SUBSTITUTEPATH_ENTRY );
|
|
461 |
OstTraceExt1( TRACE_NORMAL, CDPSTRANSACTION_SUBSTITUTEPATH, "path %s", aPath );
|
|
462 |
|
29
|
463 |
TInt size = aPath.Size();
|
|
464 |
for (TInt i = 0; i < size; i++)
|
|
465 |
{
|
|
466 |
if (aPath[i] == KSlash)
|
|
467 |
{
|
|
468 |
aPath[i] = KBackSlash;
|
|
469 |
}
|
|
470 |
}
|
|
471 |
TBuf<KPathLength> driveEWide = PathInfo::MemoryCardRootPath();
|
|
472 |
TBuf8<KPathLength> driveENarrow;
|
|
473 |
driveENarrow.Copy(driveEWide);
|
|
474 |
aPath.Replace(0, KPathLength - 1, driveENarrow);
|
49
|
475 |
OstTraceExt1( TRACE_NORMAL, DUP1_CDPSTRANSACTION_SUBSTITUTEPATH, "path %s", aPath );
|
|
476 |
OstTraceFunctionExit0( CDPSTRANSACTION_SUBSTITUTEPATH_EXIT );
|
29
|
477 |
}
|