|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include <mtp/tmtptyperequest.h> |
|
22 |
|
23 #include "cmtpresetdevice.h" |
|
24 #include "cmtpconnection.h" |
|
25 #include "cmtpdataprovidercontroller.h" |
|
26 #include "cmtpdataprovider.h" |
|
27 #include "mtpdevdppanic.h" |
|
28 #include "cmtpconnectionmgr.h" |
|
29 #include "rmtpframework.h" |
|
30 |
|
31 /** |
|
32 Two-phase construction method |
|
33 @param aFramework The data provider framework |
|
34 @param aConnection The connection from which the request comes |
|
35 @return a pointer to the created request processor object |
|
36 */ |
|
37 MMTPRequestProcessor* CMTPResetDevice::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) |
|
38 { |
|
39 CMTPResetDevice* self = new (ELeave) CMTPResetDevice(aFramework, aConnection); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 /** |
|
47 Destructor |
|
48 */ |
|
49 CMTPResetDevice::~CMTPResetDevice() |
|
50 { |
|
51 iSingletons.Close(); |
|
52 } |
|
53 |
|
54 /** |
|
55 Standard c++ constructor |
|
56 */ |
|
57 CMTPResetDevice::CMTPResetDevice(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : |
|
58 CMTPRequestProcessor(aFramework, aConnection, 0, NULL) |
|
59 { |
|
60 |
|
61 } |
|
62 |
|
63 /** |
|
64 Second phase constructor. |
|
65 */ |
|
66 void CMTPResetDevice::ConstructL() |
|
67 { |
|
68 iSingletons.OpenL(); |
|
69 } |
|
70 |
|
71 /** |
|
72 Request checker |
|
73 */ |
|
74 TMTPResponseCode CMTPResetDevice::CheckRequestL() |
|
75 { |
|
76 TMTPResponseCode response = CMTPRequestProcessor::CheckRequestL(); |
|
77 if (response == EMTPRespCodeOK) |
|
78 { |
|
79 TUint32 sessionId = iRequest->Uint32(TMTPTypeRequest::ERequestParameter1); |
|
80 //default session (with id 0) should never be closed |
|
81 if (!iConnection.SessionWithMTPIdExists(sessionId) || sessionId == 0) |
|
82 { |
|
83 response = EMTPRespCodeSessionNotOpen; |
|
84 } |
|
85 } |
|
86 return response; |
|
87 } |
|
88 |
|
89 /** |
|
90 ResetDevice request handler. Simply close the session because we don't support multiple session for now. |
|
91 */ |
|
92 void CMTPResetDevice::ServiceL() |
|
93 { |
|
94 // Send response first before close the session |
|
95 SendResponseL(EMTPRespCodeOK); |
|
96 |
|
97 TUint connectionId = iConnection.ConnectionId(); |
|
98 CMTPConnectionMgr& connectionMgr = iSingletons.ConnectionMgr(); |
|
99 CMTPConnection& connection = connectionMgr.ConnectionL(connectionId); |
|
100 connection.SessionClosedL(0x0FFFFFFF); |
|
101 } |
|
102 |