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 implements the dps script sending function.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <f32file.h>
|
|
20 |
#include "dpsscriptsender.h"
|
|
21 |
#include "dpsstatemachine.h"
|
|
22 |
#include "pictbridge.h"
|
|
23 |
#include "dpstransaction.h"
|
|
24 |
#include "dpsfile.h"
|
49
|
25 |
#include "OstTraceDefinitions.h"
|
|
26 |
#ifdef OST_TRACE_COMPILER_IN_USE
|
|
27 |
#include "dpsscriptsenderTraces.h"
|
29
|
28 |
#endif
|
|
29 |
|
|
30 |
// ---------------------------------------------------------------------------
|
|
31 |
//
|
|
32 |
// ---------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
CDpsScriptSender* CDpsScriptSender::NewL(CDpsStateMachine* aOperator)
|
|
35 |
{
|
|
36 |
CDpsScriptSender* self = new(ELeave) CDpsScriptSender(aOperator);
|
|
37 |
return self;
|
|
38 |
}
|
|
39 |
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CDpsScriptSender::CDpsScriptSender(CDpsStateMachine* aOperator) :
|
|
45 |
CActive(EPriorityNormal), iOperator(aOperator),
|
|
46 |
iReply(EFalse)
|
|
47 |
{
|
49
|
48 |
OstTraceFunctionEntry0( CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_CONS_ENTRY );
|
29
|
49 |
CActiveScheduler::Add(this);
|
49
|
50 |
OstTraceFunctionExit0( CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_CONS_EXIT );
|
29
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
CDpsScriptSender::~CDpsScriptSender()
|
|
58 |
{
|
49
|
59 |
OstTraceFunctionEntry0( DUP1_CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_DES_ENTRY );
|
29
|
60 |
Cancel();
|
49
|
61 |
OstTraceFunctionExit0( DUP1_CDPSSCRIPTSENDER_CDPSSCRIPTSENDER_DES_EXIT );
|
29
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
//
|
|
68 |
TInt CDpsScriptSender::SendScript(TBool aReply)
|
|
69 |
{
|
49
|
70 |
OstTraceFunctionEntry0( CDPSSCRIPTSENDER_SENDSCRIPT_ENTRY );
|
29
|
71 |
if (!IsActive())
|
|
72 |
{
|
|
73 |
iReply = aReply;
|
|
74 |
TFileName file(iOperator->DpsEngine()->DpsFolder());
|
|
75 |
RFile script;
|
|
76 |
if (aReply)
|
|
77 |
{
|
|
78 |
file.Append(KDpsDeviceResponseFileName);
|
|
79 |
}
|
|
80 |
else
|
|
81 |
{
|
|
82 |
file.Append(KDpsDeviceRequestFileName);
|
|
83 |
}
|
|
84 |
TInt err = script.Open(iOperator->Trader()->
|
|
85 |
FileHandle()->FileSession(), file, EFileRead);
|
|
86 |
if (err != KErrNone)
|
|
87 |
{
|
49
|
88 |
OstTraceFunctionExit0( CDPSSCRIPTSENDER_SENDSCRIPT_EXIT );
|
29
|
89 |
return err;
|
|
90 |
}
|
|
91 |
TInt size;
|
|
92 |
script.Size(size);
|
|
93 |
script.Close();
|
|
94 |
if (aReply)
|
|
95 |
{
|
|
96 |
iOperator->DpsEngine()->
|
|
97 |
Ptp().SendObject(file, iStatus, EFalse, size);
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
iOperator->DpsEngine()->
|
|
102 |
Ptp().SendObject(file, iStatus, ETrue, size);
|
|
103 |
}
|
|
104 |
SetActive();
|
49
|
105 |
OstTraceFunctionExit0( DUP1_CDPSSCRIPTSENDER_SENDSCRIPT_EXIT );
|
29
|
106 |
return KErrNone;
|
|
107 |
}
|
|
108 |
else
|
|
109 |
{
|
49
|
110 |
OstTraceFunctionExit0( DUP2_CDPSSCRIPTSENDER_SENDSCRIPT_EXIT );
|
29
|
111 |
return KErrInUse;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
//
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CDpsScriptSender::RunL()
|
|
120 |
{
|
49
|
121 |
OstTraceFunctionEntry0( CDPSSCRIPTSENDER_RUNL_ENTRY );
|
29
|
122 |
|
|
123 |
if (KErrNone == iStatus.Int())
|
|
124 |
{
|
|
125 |
// the device request is sent
|
|
126 |
if (!iReply)
|
|
127 |
{
|
|
128 |
iOperator->ScriptSentNotifyL(EFalse);
|
|
129 |
}
|
|
130 |
// the device response is sent
|
|
131 |
else
|
|
132 |
{
|
|
133 |
iOperator->ScriptSentNotifyL(ETrue);
|
|
134 |
}
|
|
135 |
}
|
|
136 |
else
|
|
137 |
{
|
49
|
138 |
OstTrace1( TRACE_ERROR, CDPSSCRIPTSENDER_RUNL, "the iStatus is wrong %d!!!", iStatus.Int() );
|
29
|
139 |
iOperator->Error(iStatus.Int());
|
|
140 |
}
|
49
|
141 |
OstTraceFunctionExit0( CDPSSCRIPTSENDER_RUNL_EXIT );
|
29
|
142 |
}
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
// ---------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void CDpsScriptSender::DoCancel()
|
|
149 |
{
|
49
|
150 |
OstTraceFunctionEntry0( CDPSSCRIPTSENDER_DOCANCEL_ENTRY );
|
29
|
151 |
iOperator->DpsEngine()->Ptp().CancelSendObject();
|
49
|
152 |
OstTraceFunctionExit0( CDPSSCRIPTSENDER_DOCANCEL_EXIT );
|
29
|
153 |
}
|
|
154 |
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
//
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
//
|
|
159 |
TInt CDpsScriptSender::RunError(TInt aError)
|
|
160 |
{
|
49
|
161 |
OstTraceFunctionEntry0( CDPSSCRIPTSENDER_RUNERROR_ENTRY );
|
|
162 |
OstTraceDef1( OST_TRACE_CATEGORY_PRODUCTION, TRACE_IMPORTANT, CDPSSCRIPTSENDER_RUNERROR,
|
|
163 |
"error code %d", aError);
|
29
|
164 |
Cancel();
|
|
165 |
iOperator->Error(aError);
|
49
|
166 |
OstTraceFunctionExit0( CDPSSCRIPTSENDER_RUNERROR_EXIT );
|
29
|
167 |
return KErrNone;
|
|
168 |
}
|