|
1 // Copyright (c) 2010 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 // Flow / Binder |
|
15 // (data plane) |
|
16 // |
|
17 // |
|
18 // This is a 3-plane comms layer implementation example, which has been customised to be a test layer which gobbles and releases ESOCK MBUFs. |
|
19 // The MBuf gobbling functionality can be disabled by undefining the macro SYMBIAN_COMMSFW_MBUF_GOBBLER which is specified in mbufgobblerproviders.mmp. |
|
20 // When SYMBIAN_COMMSFW_MBUF_GOBBLER is undefined, the source code specified by mbufgobblerproviders.mmp becomes a pass through layer i.e. it passes the data |
|
21 // through to the layer above or below without altering it. This makes it useful as a starting point for implementing your own layers / providers; |
|
22 // useful documentation on how to customise your own passthrough layer can be found in ..\docs\MbufGobblerLayer.doc |
|
23 // |
|
24 |
|
25 /** |
|
26 @file |
|
27 @internalComponent |
|
28 */ |
|
29 |
|
30 #ifndef MBUFGOBBLERFLOW_H |
|
31 #define MBUFGOBBLERFLOW_H |
|
32 |
|
33 #include <elements/nm_signatures.h> |
|
34 #include <comms-infras/ss_subconnflow.h> |
|
35 #include <comms-infras/ss_flowbinders.h> |
|
36 #include <platform/es_mbuf.h> |
|
37 #include <comms-infras/mbufchain.h> |
|
38 #include "mbufgobblertestflags.h" |
|
39 #include <e32property.h> |
|
40 |
|
41 class CMbufGobblerBinder; |
|
42 class CMBufGobbler; |
|
43 |
|
44 class CMbufGobblerFlow : public ESock::CSubConnectionFlowBase, public ESock::MFlowBinderControl |
|
45 { |
|
46 friend class CMbufGobblerFlowFactory; |
|
47 |
|
48 protected: |
|
49 CMbufGobblerFlow(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf); |
|
50 void ConstructL(); |
|
51 public: |
|
52 static CMbufGobblerFlow* NewL(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf); |
|
53 virtual ~CMbufGobblerFlow(); |
|
54 |
|
55 // from CSubConnectionFlowBase: |
|
56 virtual ESock::MFlowBinderControl* DoGetBinderControlL(); |
|
57 virtual void ReceivedL( |
|
58 const Messages::TRuntimeCtxId& aSender, |
|
59 const Messages::TNodeId& aRecipient, |
|
60 Messages::TSignatureBase& aMessage |
|
61 ); |
|
62 |
|
63 // from MFlowBinderControl: |
|
64 virtual ESock::MLowerControl* GetControlL(const TDesC8& aProtocol); |
|
65 virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl); |
|
66 virtual void Unbind( ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl); |
|
67 virtual ESock::CSubConnectionFlowBase* Flow(); |
|
68 |
|
69 // my helper methods: |
|
70 CMbufGobblerBinder* FindOrCreateBinderL(const TDesC8& aProtocol); |
|
71 |
|
72 private: |
|
73 RPointerArray<CMbufGobblerBinder> iBinders; |
|
74 |
|
75 #ifdef SYMBIAN_COMMSFW_MBUF_GOBBLER |
|
76 CMBufGobbler* iMBufGobbler; |
|
77 #endif |
|
78 }; |
|
79 |
|
80 class CMbufGobblerBinder : public CBase, |
|
81 public ESock::MLowerControl, // I receive control requests from above |
|
82 public ESock::MLowerDataSender, // I receive data from above (outgoing) |
|
83 public ESock::MUpperControl, // I receive control signals from below |
|
84 public ESock::MUpperDataReceiver // I receive data from below (incoming) |
|
85 { |
|
86 public: |
|
87 // My constructor |
|
88 static CMbufGobblerBinder* NewL(const TDesC8& aProtocolName); |
|
89 void ConstructL(); |
|
90 protected: |
|
91 CMbufGobblerBinder(const TDesC8& aProtocolName); |
|
92 public: |
|
93 virtual ~CMbufGobblerBinder(); |
|
94 |
|
95 // from ESock::MLowerControl: |
|
96 virtual TInt GetName(TDes& aName); |
|
97 virtual TInt BlockFlow(TBlockOption aOption); |
|
98 virtual TInt GetConfig(TBinderConfig& aConfig); |
|
99 virtual TInt Control(TUint aLevel, TUint aName, TDes8& aOption); |
|
100 |
|
101 // from ESock::MLowerDataSender: |
|
102 virtual ESock::MLowerDataSender::TSendResult Send(RMBufChain& aData); |
|
103 |
|
104 // from ESock::MUpperControl: |
|
105 virtual void StartSending(); |
|
106 virtual void Error(TInt anError); |
|
107 |
|
108 // from ESock::MUpperDataReceiver: |
|
109 virtual void Process(RMBufChain& aData); |
|
110 |
|
111 |
|
112 // my own methods |
|
113 TBool InUse() const {return iLowerControl || iLowerDataSender || iUpperControl || iUpperDataReceiver ; } |
|
114 void BindToUpperL(ESock::MUpperDataReceiver& aUpperDataReceiver, ESock::MUpperControl& aUpperControl); |
|
115 TBool UnbindFromUpper(ESock::MUpperDataReceiver& aUpperDataReceiver, ESock::MUpperControl& aUpperControl); |
|
116 void BindToLowerFlowL(ESock::MFlowBinderControl& aLowerControl); |
|
117 void UnbindFromLowerFlow(); // NEW UNBIND COMMAND |
|
118 const TDesC8& ProtocolName() const; |
|
119 |
|
120 private: |
|
121 ESock::MFlowBinderControl* iBinderControl; |
|
122 ESock::MLowerControl* iLowerControl; // .. so I can send controls down |
|
123 ESock::MLowerDataSender* iLowerDataSender; // .. so I can send data down (outgoing) |
|
124 ESock::MUpperControl* iUpperControl; // .. so I can send controls up (err/startsending) |
|
125 ESock::MUpperDataReceiver* iUpperDataReceiver; // .. so I can send data up (incoming) |
|
126 TBuf8<10> iProtocolName; // long enough for an acronym one would hope |
|
127 MBUFGOBBLER_TEST_DATA |
|
128 }; |
|
129 |
|
130 #ifdef SYMBIAN_COMMSFW_MBUF_GOBBLER |
|
131 |
|
132 class CMBufGobbler : public CActive |
|
133 { |
|
134 public: |
|
135 static CMBufGobbler* NewL(); |
|
136 void ConstructL(); |
|
137 protected: |
|
138 CMBufGobbler(); |
|
139 public: |
|
140 virtual ~CMBufGobbler(); |
|
141 |
|
142 // from CActive: |
|
143 virtual void DoCancel(); |
|
144 virtual void RunL(); |
|
145 |
|
146 RMBufChain iChain; |
|
147 RProperty iProperty; |
|
148 }; |
|
149 #endif |
|
150 |
|
151 #endif // MBUFGOBBLERFLOW_H |