|
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 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef MBUFGOBBLERFLOW_H |
|
24 #define MBUFGOBBLERFLOW_H |
|
25 |
|
26 #include <elements/nm_signatures.h> |
|
27 #include <comms-infras/ss_subconnflow.h> |
|
28 #include <comms-infras/ss_flowbinders.h> |
|
29 #include <platform/es_mbuf.h> |
|
30 #include <comms-infras/mbufchain.h> |
|
31 #include "mbufgobblertestflags.h" |
|
32 |
|
33 class CMbufGobblerBinder; |
|
34 class CMBufGobbler; |
|
35 |
|
36 class CMbufGobblerFlow : public ESock::CSubConnectionFlowBase, public ESock::MFlowBinderControl |
|
37 { |
|
38 friend class CMbufGobblerFlowFactory; |
|
39 |
|
40 protected: |
|
41 CMbufGobblerFlow(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf); |
|
42 void ConstructL(); |
|
43 public: |
|
44 static CMbufGobblerFlow* NewL(ESock::CSubConnectionFlowFactoryBase& aFactory, const Messages::TNodeId& aSubConnId, ESock::CProtocolIntfBase* aProtocolIntf); |
|
45 virtual ~CMbufGobblerFlow(); |
|
46 |
|
47 // from CSubConnectionFlowBase: |
|
48 virtual ESock::MFlowBinderControl* DoGetBinderControlL(); |
|
49 virtual void ReceivedL( |
|
50 const Messages::TRuntimeCtxId& aSender, |
|
51 const Messages::TNodeId& aRecipient, |
|
52 Messages::TSignatureBase& aMessage |
|
53 ); |
|
54 |
|
55 // from MFlowBinderControl: |
|
56 virtual ESock::MLowerControl* GetControlL(const TDesC8& aProtocol); |
|
57 virtual ESock::MLowerDataSender* BindL(const TDesC8& aProtocol, ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl); |
|
58 virtual void Unbind( ESock::MUpperDataReceiver* aReceiver, ESock::MUpperControl* aControl); |
|
59 virtual ESock::CSubConnectionFlowBase* Flow(); |
|
60 |
|
61 // my helper methods: |
|
62 CMbufGobblerBinder* FindOrCreateBinderL(const TDesC8& aProtocol); |
|
63 |
|
64 private: |
|
65 RPointerArray<CMbufGobblerBinder> iBinders; |
|
66 CMBufGobbler* iPassThroughMBufGobbler; |
|
67 }; |
|
68 |
|
69 class CMbufGobblerBinder : public CBase, |
|
70 public ESock::MLowerControl, // I receive control requests from above |
|
71 public ESock::MLowerDataSender, // I receive data from above (outgoing) |
|
72 public ESock::MUpperControl, // I receive control signals from below |
|
73 public ESock::MUpperDataReceiver // I receive data from below (incoming) |
|
74 { |
|
75 public: |
|
76 // My constructor |
|
77 static CMbufGobblerBinder* NewL(const TDesC8& aProtocolName); |
|
78 void ConstructL(); |
|
79 protected: |
|
80 CMbufGobblerBinder(const TDesC8& aProtocolName); |
|
81 public: |
|
82 virtual ~CMbufGobblerBinder(); |
|
83 |
|
84 // from ESock::MLowerControl: |
|
85 virtual TInt GetName(TDes& aName); |
|
86 virtual TInt BlockFlow(TBlockOption aOption); |
|
87 virtual TInt GetConfig(TBinderConfig& aConfig); |
|
88 virtual TInt Control(TUint aLevel, TUint aName, TDes8& aOption); |
|
89 |
|
90 // from ESock::MLowerDataSender: |
|
91 virtual ESock::MLowerDataSender::TSendResult Send(RMBufChain& aData); |
|
92 |
|
93 // from ESock::MUpperControl: |
|
94 virtual void StartSending(); |
|
95 virtual void Error(TInt anError); |
|
96 |
|
97 // from ESock::MUpperDataReceiver: |
|
98 virtual void Process(RMBufChain& aData); |
|
99 |
|
100 |
|
101 // my own methods |
|
102 TBool InUse() const {return iLowerControl || iLowerDataSender || iUpperControl || iUpperDataReceiver ; } |
|
103 void BindToUpperL(ESock::MUpperDataReceiver& aUpperDataReceiver, ESock::MUpperControl& aUpperControl); |
|
104 TBool UnbindFromUpper(ESock::MUpperDataReceiver& aUpperDataReceiver, ESock::MUpperControl& aUpperControl); |
|
105 void BindToLowerFlowL(ESock::MFlowBinderControl& aLowerControl); |
|
106 void UnbindFromLowerFlow(); // NEW UNBIND COMMAND |
|
107 const TDesC8& ProtocolName() const; |
|
108 |
|
109 private: |
|
110 ESock::MFlowBinderControl* iBinderControl; |
|
111 ESock::MLowerControl* iLowerControl; // .. so I can send controls down |
|
112 ESock::MLowerDataSender* iLowerDataSender; // .. so I can send data down (outgoing) |
|
113 ESock::MUpperControl* iUpperControl; // .. so I can send controls up (err/startsending) |
|
114 ESock::MUpperDataReceiver* iUpperDataReceiver; // .. so I can send data up (incoming) |
|
115 TBuf8<10> iProtocolName; // long enough for an acronym one would hope |
|
116 MBUFGOBBLER_TEST_DATA |
|
117 }; |
|
118 |
|
119 class CMBufGobbler : public CActive |
|
120 { |
|
121 public: |
|
122 static CMBufGobbler* NewL(); |
|
123 void ConstructL(); |
|
124 protected: |
|
125 CMBufGobbler(); |
|
126 public: |
|
127 virtual ~CMBufGobbler(); |
|
128 |
|
129 // from CActive: |
|
130 virtual void DoCancel(); |
|
131 virtual void RunL(); |
|
132 |
|
133 RMBufChain iChain; |
|
134 RProperty iProperty; |
|
135 }; |
|
136 |
|
137 #endif // MBUFGOBBLERFLOW_H |