|
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 * |
|
16 */ |
|
17 |
|
18 #ifndef __ACMPORT_H__ |
|
19 #define __ACMPORT_H__ |
|
20 |
|
21 #include <cs_port.h> |
|
22 #include "CdcAcmClass.h" |
|
23 #include "HostPushedChangeObserver.h" |
|
24 #include "BreakObserver.h" |
|
25 |
|
26 class CAcmPortFactory; |
|
27 class CAcmReader; |
|
28 class CAcmWriter; |
|
29 class MAcmPortObserver; |
|
30 |
|
31 NONSHARABLE_CLASS(CAcmPort) : public CPort, |
|
32 public MHostPushedChangeObserver, |
|
33 public MBreakObserver |
|
34 /** |
|
35 * Concrete ACM port type, derived from C32's CPort. |
|
36 */ |
|
37 { |
|
38 public: |
|
39 static CAcmPort* NewL(const TUint aUnit, MAcmPortObserver& aFactory); |
|
40 ~CAcmPort(); |
|
41 |
|
42 public: |
|
43 void SetAcm(CCdcAcmClass* aAcm); |
|
44 inline CCdcAcmClass* Acm(); |
|
45 |
|
46 private: |
|
47 CAcmPort(const TUint aUnit, MAcmPortObserver& aFactory); |
|
48 void ConstructL(); |
|
49 |
|
50 private: // from CPort |
|
51 virtual void StartRead(const TAny* aClientBuffer,TInt aLength); |
|
52 virtual void ReadCancel(); |
|
53 virtual TInt QueryReceiveBuffer(TInt& aLength) const; |
|
54 virtual void ResetBuffers(TUint aFlags); |
|
55 virtual void StartWrite(const TAny* aClientBuffer,TInt aLength); |
|
56 virtual void WriteCancel(); |
|
57 virtual void Break(TInt aTime); |
|
58 virtual void BreakCancel(); |
|
59 virtual TInt GetConfig(TDes8& aDes) const; |
|
60 virtual TInt SetConfig(const TDesC8& aDes); |
|
61 virtual TInt SetServerConfig(const TDesC8& aDes); |
|
62 virtual TInt GetServerConfig(TDes8& aDes); |
|
63 virtual TInt GetCaps(TDes8& aDes); |
|
64 virtual TInt GetSignals(TUint& aSignals); |
|
65 virtual TInt SetSignalsToMark(TUint aSignals); |
|
66 virtual TInt SetSignalsToSpace(TUint aSignals); |
|
67 virtual TInt GetReceiveBufferLength(TInt& aLength) const; |
|
68 virtual TInt SetReceiveBufferLength(TInt aSignals); |
|
69 virtual void Destruct(); |
|
70 virtual void FreeMemory(); |
|
71 virtual void NotifySignalChange(TUint aSignalMask); |
|
72 virtual void NotifySignalChangeCancel(); |
|
73 virtual void NotifyConfigChange(); |
|
74 virtual void NotifyConfigChangeCancel(); |
|
75 virtual void NotifyFlowControlChange(); |
|
76 virtual void NotifyFlowControlChangeCancel(); |
|
77 virtual void NotifyBreak(); |
|
78 virtual void NotifyBreakCancel(); |
|
79 virtual void NotifyDataAvailable(); |
|
80 virtual void NotifyDataAvailableCancel(); |
|
81 virtual void NotifyOutputEmpty(); |
|
82 virtual void NotifyOutputEmptyCancel(); |
|
83 virtual TInt GetFlowControlStatus(TFlowControl& aFlowControl); |
|
84 virtual TInt GetRole(TCommRole& aRole); |
|
85 virtual TInt SetRole(TCommRole aRole); |
|
86 |
|
87 private: // from MBreakObserver |
|
88 void BreakRequestCompleted(); |
|
89 void BreakStateChange(); |
|
90 |
|
91 private: // from MHostPushedChangeObserver |
|
92 virtual void HostConfigChange(const TCommConfigV01& aConfig); |
|
93 virtual void HostSignalChange(TBool aDtr, TBool aRts); |
|
94 |
|
95 private: // utility |
|
96 TInt SetSignals(TUint32 aNewSignals); |
|
97 void HandleConfigNotification(TBps aBps, |
|
98 TDataBits aDataBits, |
|
99 TParity aParity, |
|
100 TStopBits aStopBits, |
|
101 TUint aHandshake); |
|
102 // iSignals stores the lines in DCE mode- these functions convert between |
|
103 // this and whatever the client expects, according to our current mode. |
|
104 TUint32 ConvertSignals(TUint32 aSignals) const; |
|
105 TUint32 ConvertAndFilterSignals(TUint32 aSignals) const; |
|
106 TInt DoSetBufferLengths(TUint aLength); |
|
107 |
|
108 public: // owned data |
|
109 TCommConfigV01 iCommConfig; |
|
110 TCommNotificationPckg iCommNotificationDes; |
|
111 TCommNotificationV01& iCommNotification; |
|
112 |
|
113 private: // unowned |
|
114 CCdcAcmClass* iAcm; |
|
115 MAcmPortObserver& iObserver; |
|
116 |
|
117 private: // owned |
|
118 CAcmReader* iReader; |
|
119 CAcmWriter* iWriter; |
|
120 |
|
121 // Current server configuration settings |
|
122 TCommServerConfigV01 iCommServerConfig; |
|
123 // Flag indicating whether there is a current signal line change |
|
124 // notification request outstanding |
|
125 TBool iNotifySignalChange; |
|
126 // Flag indicating whether there is a current configuration change |
|
127 // notification request outstanding |
|
128 TBool iNotifyConfigChange; |
|
129 // Flag indicating whether there is a current break notification |
|
130 // request outstanding |
|
131 TBool iNotifyBreak; |
|
132 // The current emulated signal lines |
|
133 TUint32 iSignals; |
|
134 // The signal mask associated with the current signal change notification |
|
135 // request |
|
136 TUint iNotifySignalMask; |
|
137 // Role of the serial port (DTE or DCE) |
|
138 TCommRole iRole; |
|
139 TBool iCancellingBreak; |
|
140 // Flag indicating whether we're currently requesting a break. |
|
141 TBool iBreak; |
|
142 |
|
143 // The port number. |
|
144 const TUint iUnit; |
|
145 }; |
|
146 |
|
147 // Inlines |
|
148 |
|
149 CCdcAcmClass* CAcmPort::Acm() |
|
150 /** |
|
151 * Accessor function for the ACM class. |
|
152 * |
|
153 * @return Pointer to the port's ACM class instance. |
|
154 */ |
|
155 { |
|
156 return iAcm; |
|
157 } |
|
158 |
|
159 #endif // __ACMPORT_H__ |