|
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 "cmtpusbsicclasscontroller.h" |
|
22 #include <musbclasscontrollernotify.h> |
|
23 #include "mtpdebug.h" |
|
24 #include "mtpusbprotocolconstants.h" |
|
25 |
|
26 const TInt KSicCCStartupPriority = 3; |
|
27 |
|
28 // Class constants. |
|
29 __FLOG_STMT(_LIT8(KComponent,"CMTPUsbSicClassController");) |
|
30 |
|
31 /** |
|
32 This method returns a pointer to a newly created CMTPUsbSicClassController object. |
|
33 @param aOwner USB Device that owns and manages the class. |
|
34 @return a newly created CMTPUsbSicClassController object. |
|
35 */ |
|
36 CMTPUsbSicClassController* CMTPUsbSicClassController::NewL(MUsbClassControllerNotify& aOwner) |
|
37 { |
|
38 CMTPUsbSicClassController* self = new (ELeave) CMTPUsbSicClassController(aOwner); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 /** |
|
46 Destructor |
|
47 */ |
|
48 CMTPUsbSicClassController::~CMTPUsbSicClassController() |
|
49 { |
|
50 __FLOG(_L8("~CMTPUsbSicClassController - Entry")); |
|
51 Cancel(); |
|
52 __FLOG(_L8("~CMTPUsbSicClassController - Exit")); |
|
53 __FLOG_CLOSE; |
|
54 } |
|
55 |
|
56 /** |
|
57 Constructor |
|
58 @param aOwner USB Device that owns and manages the class. |
|
59 */ |
|
60 CMTPUsbSicClassController::CMTPUsbSicClassController(MUsbClassControllerNotify& aOwner): |
|
61 CUsbClassControllerPlugIn(aOwner, KSicCCStartupPriority) |
|
62 { |
|
63 // do nothing. |
|
64 } |
|
65 |
|
66 /** |
|
67 Second phase constructor. |
|
68 */ |
|
69 void CMTPUsbSicClassController::ConstructL() |
|
70 { |
|
71 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
72 __FLOG(_L8("ConstructL - Entry")); |
|
73 __FLOG(_L8("ConstructL - Exit")); |
|
74 } |
|
75 |
|
76 /** |
|
77 Called by UsbMan when it wants to start the MTP USB Still Image Capture class. |
|
78 @param aStatus The caller's request status, filled in with an error code |
|
79 */ |
|
80 void CMTPUsbSicClassController::Start(TRequestStatus& aStatus) |
|
81 { |
|
82 __FLOG(_L8("Start - Entry")); |
|
83 TRequestStatus* reportStatus = &aStatus; |
|
84 |
|
85 iState = EUsbServiceStarting; |
|
86 |
|
87 // Connect to MTP server |
|
88 TInt err = iMTPSession.Connect(); |
|
89 |
|
90 if (err != KErrNone) |
|
91 { |
|
92 __FLOG_VA((_L8("iMTPSession.Connect() failed with %d"), err)); |
|
93 iState = EUsbServiceIdle; |
|
94 User::RequestComplete(reportStatus, err); |
|
95 return; |
|
96 } |
|
97 // Start MTP USB Still Image class transport. |
|
98 err = iMTPSession.StartTransport(TUid::Uid(KMTPUsbTransportImplementationUid)); |
|
99 __FLOG_VA((_L8("StartTransport returns %d"), err)); |
|
100 if (err != KErrNone) |
|
101 { |
|
102 iState = EUsbServiceIdle; |
|
103 iMTPSession.Close(); |
|
104 } |
|
105 else |
|
106 { |
|
107 iState = EUsbServiceStarted; |
|
108 } |
|
109 |
|
110 User::RequestComplete(reportStatus, err); |
|
111 __FLOG(_L8("Start - Exit")); |
|
112 } |
|
113 |
|
114 |
|
115 /** |
|
116 Called by UsbMan when it wants to stop the USB Still Image Capture class. |
|
117 @param aStatus KErrNone on success or a system wide error code |
|
118 */ |
|
119 void CMTPUsbSicClassController::Stop(TRequestStatus& aStatus) |
|
120 { |
|
121 __FLOG(_L8("Stop - Entry")); |
|
122 TRequestStatus* reportStatus = &aStatus; |
|
123 |
|
124 TInt err = iMTPSession.StopTransport(TUid::Uid(KMTPUsbTransportImplementationUid)); |
|
125 __FLOG_VA((_L8("StopTransport returns %d"), err)); |
|
126 if (err != KErrNone) |
|
127 { |
|
128 iState = EUsbServiceStarted; |
|
129 User::RequestComplete(reportStatus, err); |
|
130 return; |
|
131 } |
|
132 iMTPSession.Close(); |
|
133 |
|
134 User::RequestComplete(reportStatus, KErrNone); |
|
135 __FLOG(_L8("Stop - Exit")); |
|
136 } |
|
137 |
|
138 |
|
139 /** |
|
140 Gets information about the descriptor which this class provides. Never called |
|
141 by usbMan. |
|
142 @param aDescriptorInfo Descriptor info structure filled in by this function |
|
143 */ |
|
144 void CMTPUsbSicClassController::GetDescriptorInfo(TUsbDescriptor& /*aDescriptorInfo*/) const |
|
145 { |
|
146 // do nothing. |
|
147 } |
|
148 |
|
149 /** |
|
150 RunL of CActive. Never called because this class has no |
|
151 asynchronous requests. |
|
152 */ |
|
153 void CMTPUsbSicClassController::RunL() |
|
154 { |
|
155 // do nothing. |
|
156 } |
|
157 |
|
158 /** |
|
159 DoCancel of CActive. Never called because this class has no |
|
160 asynchronous requests. |
|
161 */ |
|
162 void CMTPUsbSicClassController::DoCancel() |
|
163 { |
|
164 // do nothing. |
|
165 } |
|
166 |
|
167 /** |
|
168 RunError of CActive. Never called because this class has no |
|
169 asynchronous requests. |
|
170 */ |
|
171 TInt CMTPUsbSicClassController::RunError(TInt /*aError*/) |
|
172 { |
|
173 // avoid the panic of CActiveScheduler. |
|
174 return KErrNone; |
|
175 } |
|
176 |