17 |
17 |
18 /** |
18 /** |
19 @file |
19 @file |
20 */ |
20 */ |
21 |
21 |
22 |
|
23 #include "OstTraceDefinitions.h" |
|
24 #ifdef OST_TRACE_COMPILER_IN_USE |
|
25 #include "SenderTraces.h" |
|
26 #endif |
|
27 |
|
28 #include "Sender.h" |
22 #include "Sender.h" |
29 #include "Constants.h" |
23 #include "Constants.h" |
30 #include <es_ini.h> |
24 #include <es_ini.h> |
31 |
25 |
32 |
26 |
33 CSender::CSender(CBcaIoController& aObserver, TInt aMaxPacketSise) |
27 CSender::CSender(CBcaIoController& aObserver, CBttLogger* aTheLogger, TInt aMaxPacketSise) |
34 /** |
28 /** |
35 * Constructor. Performs standard active object initialisation. |
29 * Constructor. Performs standard active object initialisation. |
|
30 * |
36 * @param aObserver Reference to the observer of this state machine |
31 * @param aObserver Reference to the observer of this state machine |
37 */ |
32 */ |
38 : CActive(EPriorityUserInput), |
33 : CActive(EPriorityUserInput), |
39 iObserver(aObserver), |
34 iObserver(aObserver), |
|
35 iTheLogger(aTheLogger), |
40 iMaxPacketSize(aMaxPacketSise) |
36 iMaxPacketSize(aMaxPacketSise) |
41 { |
37 { |
42 // EPriorityUserInput is higher than the default priority but lower than |
38 // EPriorityUserInput is higher than the default priority but lower than |
43 // EPriorityHigh which is used on Receiving (DL having priority), however, |
39 // EPriorityHigh which is used on Receiving (DL having priority), however, |
44 // we want this to be handled in an expedited manner compared to other |
40 // we want this to be handled in an expedited manner compared to other |
45 // active objects in the thread. |
41 // active objects in the thread. |
46 CActiveScheduler::Add(this); |
42 CActiveScheduler::Add(this); |
47 } |
43 } |
48 |
44 |
49 CSender* CSender::NewL(CBcaIoController& aObserver, TInt aMaxPacketSise) |
45 CSender* CSender::NewL(CBcaIoController& aObserver, CBttLogger* aTheLogger, TInt aMaxPacketSise) |
50 /** |
46 /** |
51 * Two-phase constructor. Creates a new CBcaIoController object, performs |
47 * Two-phase constructor. Creates a new CBcaIoController object, performs |
52 * second-phase construction, then returns it. |
48 * second-phase construction, then returns it. |
53 * |
49 * |
54 * @param aObserver The observer, to which events will be reported |
50 * @param aObserver The observer, to which events will be reported |
|
51 * @param aTheLogger The logging object |
55 * @return A newly constructed CBcaIoController object |
52 * @return A newly constructed CBcaIoController object |
56 */ |
53 */ |
57 { |
54 { |
58 CSender* self = new (ELeave) CSender(aObserver, aMaxPacketSise); |
55 CSender* self = new (ELeave) CSender(aObserver, aTheLogger, aMaxPacketSise); |
59 CleanupStack::PushL(self); |
56 CleanupStack::PushL(self); |
60 self->ConstructL(); |
57 self->ConstructL(); |
61 CleanupStack::Pop(self); |
58 CleanupStack::Pop(self); |
62 return self; |
59 return self; |
63 } |
60 } |
86 void CSender::RunL() |
83 void CSender::RunL() |
87 /** |
84 /** |
88 * This method checks if any error occured in the write operation. |
85 * This method checks if any error occured in the write operation. |
89 */ |
86 */ |
90 { |
87 { |
91 OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_1, "CSender::RunL [iStatus=%d]", iStatus.Int()); |
88 _LOG_L1C2(_L8("CSender::RunL [iStatus=%d]"), iStatus.Int()); |
92 |
89 |
93 if (iStatus!=KErrNone) |
90 if (iStatus!=KErrNone) |
94 { |
91 { |
95 if(iStatus == KErrNoMemory) |
92 if(iStatus == KErrNoMemory) |
96 { |
93 { |
97 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_2, "WARNING! CSender: Write failed with KErrNoMemory"); |
94 _LOG_L2C1(_L8("WARNING! CSender: Write failed with KErrNoMemory")); |
98 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_3, "WARNING! CSender: Ignoring packet!!!!"); |
95 _LOG_L2C1(_L8("WARNING! CSender: Ignoring packet!!!!")); |
99 // Write operation failed!! Nif will ignore this packet. |
96 // Write operation failed!! Nif will ignore this packet. |
100 iObserver.SendComplete(); |
97 iObserver.SendComplete(); |
101 } |
98 } |
102 else if (iStatus == KErrNotReady) |
99 else if (iStatus == KErrNotReady) |
103 { |
100 { |
104 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_4, "WARNING! CSender: Write failed with KErrNotReady"); |
101 _LOG_L2C1(_L8("WARNING! CSender: Write failed with KErrNotReady")); |
105 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_5, "WARNING! CSender: Ignoring packet!!!!"); |
102 _LOG_L2C1(_L8("WARNING! CSender: Ignoring packet!!!!")); |
106 // Write operation failed!! Nif will ignore this packet. |
103 // Write operation failed!! Nif will ignore this packet. |
107 iObserver.SendComplete(); |
104 iObserver.SendComplete(); |
108 } |
105 } |
109 else |
106 else |
110 { |
107 { |
111 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_6, "ERROR! CSender: Write failed!!!!"); |
108 _LOG_L2C1(_L8("ERROR! CSender: Write failed!!!!")); |
112 // Nif will shut down |
109 // Nif will shut down |
113 iObserver.Stop(iStatus.Int()); |
110 iObserver.Stop(iStatus.Int()); |
114 } |
111 } |
115 return; |
112 return; |
116 } |
113 } |
117 |
114 |
118 else |
115 else |
119 { |
116 { |
120 // The Ip packet was sent successfuly |
117 // The Ip packet was sent successfuly |
121 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_RUNL_7, "***** CSender: Packet Sent."); |
118 _LOG_L1C1(_L8("***** CSender: Packet Sent.")); |
122 iObserver.SendComplete(); |
119 iObserver.SendComplete(); |
123 } |
120 } |
124 } |
121 } |
125 |
122 |
126 void CSender::DoCancel() |
123 void CSender::DoCancel() |
127 /** |
124 /** |
128 * Cancel active request |
125 * Cancel active request |
129 */ |
126 */ |
130 { |
127 { |
131 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_DOCANCEL_1, "CSender::DoCancel"); |
128 _LOG_L1C1(_L8("CSender::DoCancel")); |
132 |
129 |
133 (iObserver.Bca())->CancelWrite(); |
130 (iObserver.Bca())->CancelWrite(); |
134 } |
131 } |
135 |
132 |
136 void CSender::Send(RMBufChain& aPdu) |
133 void CSender::Send(RMBufChain& aPdu) |
139 * |
136 * |
140 * @param aPdu The IP packet to be sent. |
137 * @param aPdu The IP packet to be sent. |
141 * @return KStopSending, or KErrArgument if the packet is too large. |
138 * @return KStopSending, or KErrArgument if the packet is too large. |
142 */ |
139 */ |
143 { |
140 { |
144 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CSENDER_SEND_1, "CSender::Send"); |
141 _LOG_L1C1(_L8("CSender::Send")); |
145 |
142 |
146 // Copy the IP portion of the RMBufChain to the buffer. |
143 // Copy the IP portion of the RMBufChain to the buffer. |
147 iSendBuffer.SetMax(); |
144 iSendBuffer.SetMax(); |
148 aPdu.CopyOut(iSendBuffer, aPdu.First()->Length()); |
145 aPdu.CopyOut(iSendBuffer, aPdu.First()->Length()); |
149 |
146 |