|
1 /** |
|
2 * Copyright (c) 1997-2009 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: |
|
15 * Adheres to the UsbMan USB Class API and talks to C32 |
|
16 * to manage the ACM.CSY that is used to provide a virtual |
|
17 * serial port service to clients |
|
18 * |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @file |
|
26 */ |
|
27 |
|
28 #ifndef __CUSBACMCLASSCONTROLLER_H__ |
|
29 #define __CUSBACMCLASSCONTROLLER_H__ |
|
30 |
|
31 #include <e32std.h> |
|
32 #include <cusbclasscontrollerplugin.h> |
|
33 #ifdef USE_ACM_REGISTRATION_PORT |
|
34 #include <c32comm.h> |
|
35 #else |
|
36 #include <usb/acmserver.h> |
|
37 #endif |
|
38 class MUsbClassControllerNotify; |
|
39 class CIniFile; |
|
40 |
|
41 const TInt KAcmStartupPriority = 3; |
|
42 const TUint KDefaultNumberOfAcmFunctions = 1; |
|
43 const TInt KMaximumAcmFunctions = 15; |
|
44 |
|
45 const TInt KAcmNumberOfInterfacesPerAcmFunction = 2; // data and control interfaces |
|
46 // The name of the ini file specifying the number of ACM functions required and optionally their interface names |
|
47 _LIT(KAcmFunctionsIniFileName, "NumberOfAcmFunctions.ini"); |
|
48 _LIT(KAcmConfigSection,"ACM_CONF"); |
|
49 _LIT(KNumberOfAcmFunctionsKeyWord,"NumberOfAcmFunctions"); |
|
50 |
|
51 _LIT(KAcmSettingsSection,"ACM %d"); |
|
52 _LIT(KAcmProtocolNum,"ProtocolNum"); |
|
53 _LIT(KAcmControlIfcName,"ControlInterfaceName"); |
|
54 _LIT(KAcmDataIfcName,"DataInterfaceName"); |
|
55 |
|
56 // Lengths of the various bits of the ACM descriptor. Taken from the USB |
|
57 // WMCDC specification, v1.0. |
|
58 const TInt KAcmInterfaceDescriptorLength = 3; |
|
59 const TInt KAcmCcHeaderDescriptorLength = 5; |
|
60 const TInt KAcmFunctionalDescriptorLength = 4; |
|
61 const TInt KAcmCcUfdDescriptorLength = 5; |
|
62 const TInt KAcmNotificationEndpointDescriptorLength = 7; |
|
63 const TInt KAcmDataClassInterfaceDescriptorLength = 3; |
|
64 const TInt KAcmDataClassHeaderDescriptorLength = 5; |
|
65 const TInt KAcmDataClassEndpointInDescriptorLength = 7; |
|
66 const TInt KAcmDataClassEndpointOutDescriptorLength = 7; |
|
67 |
|
68 const TInt KAcmDescriptorLength = |
|
69 KAcmInterfaceDescriptorLength + |
|
70 KAcmCcHeaderDescriptorLength + |
|
71 KAcmFunctionalDescriptorLength + |
|
72 KAcmCcUfdDescriptorLength + |
|
73 KAcmNotificationEndpointDescriptorLength + |
|
74 KAcmDataClassInterfaceDescriptorLength + |
|
75 KAcmDataClassHeaderDescriptorLength + |
|
76 KAcmDataClassEndpointInDescriptorLength + |
|
77 KAcmDataClassEndpointOutDescriptorLength; |
|
78 |
|
79 /** |
|
80 * The CUsbACMClassController class |
|
81 * |
|
82 * Implements the USB Class Controller API and manages the ACM.CSY |
|
83 */ |
|
84 NONSHARABLE_CLASS(CUsbACMClassController) : public CUsbClassControllerPlugIn |
|
85 { |
|
86 |
|
87 public: // New functions. |
|
88 static CUsbACMClassController* NewL(MUsbClassControllerNotify& aOwner); |
|
89 |
|
90 public: // Functions derived from CBase. |
|
91 virtual ~CUsbACMClassController(); |
|
92 |
|
93 public: // Functions derived from CActive. |
|
94 virtual void RunL(); |
|
95 virtual void DoCancel(); |
|
96 virtual TInt RunError(TInt aError); |
|
97 |
|
98 public: // Functions derived from CUsbClassControllerBase |
|
99 virtual void Start(TRequestStatus& aStatus); |
|
100 virtual void Stop(TRequestStatus& aStatus); |
|
101 |
|
102 virtual void GetDescriptorInfo(TUsbDescriptor& aDescriptorInfo) const; |
|
103 |
|
104 protected: |
|
105 CUsbACMClassController(MUsbClassControllerNotify& aOwner); |
|
106 void ConstructL(); |
|
107 |
|
108 private: |
|
109 void DoStartL(); |
|
110 void ReadAcmConfigurationL(); |
|
111 void DoStop(); |
|
112 void ReadAcmIniDataL(CIniFile* aIniFile, TUint aCount, RBuf& aAcmControlIfcName, RBuf& aAcmDataIfcName); |
|
113 |
|
114 private: |
|
115 #ifdef USE_ACM_REGISTRATION_PORT |
|
116 RCommServ iCommServer; |
|
117 RComm iComm; |
|
118 #else |
|
119 RAcmServer iAcmServer; |
|
120 #endif |
|
121 TInt iNumberOfAcmFunctions; |
|
122 TFixedArray<TUint8, KMaximumAcmFunctions> iAcmProtocolNum; |
|
123 TFixedArray<RBuf, KMaximumAcmFunctions> iAcmControlIfcName; |
|
124 TFixedArray<RBuf, KMaximumAcmFunctions> iAcmDataIfcName; |
|
125 }; |
|
126 |
|
127 #endif //__CUSBACMCLASSCONTROLLER_H__ |