|
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 "cmtpopensession.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 Verification data for OpenSession request |
|
33 */ |
|
34 const TMTPRequestElementInfo KMTPOpenSessionPolicy[] = |
|
35 { |
|
36 {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeSessionID, EMTPElementAttrNone, 0, 0, 0} |
|
37 }; |
|
38 |
|
39 /** |
|
40 Two-phase construction method |
|
41 @param aPlugin The data provider plugin |
|
42 @param aFramework The data provider framework |
|
43 @param aConnection The connection from which the request comes |
|
44 @return a pointer to the created request processor object |
|
45 */ |
|
46 MMTPRequestProcessor* CMTPOpenSession::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) |
|
47 { |
|
48 CMTPOpenSession* self = new (ELeave) CMTPOpenSession(aFramework, aConnection); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 /** |
|
56 Destructor |
|
57 */ |
|
58 CMTPOpenSession::~CMTPOpenSession() |
|
59 { |
|
60 iSingletons.Close(); |
|
61 } |
|
62 |
|
63 /** |
|
64 Standard c++ constructor |
|
65 */ |
|
66 CMTPOpenSession::CMTPOpenSession(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) : |
|
67 CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPOpenSessionPolicy)/sizeof(TMTPRequestElementInfo), KMTPOpenSessionPolicy) |
|
68 { |
|
69 |
|
70 } |
|
71 |
|
72 /** |
|
73 Second phase constructor. |
|
74 */ |
|
75 void CMTPOpenSession::ConstructL() |
|
76 { |
|
77 iSingletons.OpenL(); |
|
78 } |
|
79 |
|
80 /** |
|
81 OpenSession request handler. Adds the session to the connection. |
|
82 */ |
|
83 void CMTPOpenSession::ServiceL() |
|
84 { |
|
85 iSingletons.DpController().WaitForEnumerationComplete(); |
|
86 if(iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumerated) |
|
87 { |
|
88 SendResponseL(EMTPRespCodeDeviceBusy); |
|
89 } |
|
90 else |
|
91 { |
|
92 const TUint connectionId = iConnection.ConnectionId(); |
|
93 CMTPConnectionMgr& connectionMgr = iSingletons.ConnectionMgr(); |
|
94 CMTPConnection& connection = connectionMgr.ConnectionL(connectionId); |
|
95 connection.SessionOpenedL(Request().Uint32(TMTPTypeRequest::ERequestParameter1)); |
|
96 SendResponseL(EMTPRespCodeOK); |
|
97 } |
|
98 } |