1 // Copyright (c) 1997-2009 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 // |
|
15 |
|
16 #include <obex/transport/obexactivereader.h> |
|
17 #include <es_sock.h> |
|
18 #include "logger.h" |
|
19 |
|
20 #ifdef __FLOG_ACTIVE |
|
21 _LIT8(KLogComponent, "OBEXCT"); |
|
22 #endif |
|
23 |
|
24 /** |
|
25 Factory function. |
|
26 @param aOwner the owner of this |
|
27 @param aSocket a socket for reading and writing |
|
28 @param aInfo connection information |
|
29 @return Ownership of a new active reader. |
|
30 */ |
|
31 EXPORT_C CObexActiveReader* CObexActiveReader::NewL(MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo) |
|
32 { |
|
33 CObexActiveReader* self = new(ELeave) CObexActiveReader(aOwner, aSocket, aInfo); |
|
34 CleanupStack::PushL(self); |
|
35 self->BaseConstructL(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 /** |
|
41 Constructor |
|
42 @param aOwner the owner of this |
|
43 @param aSocket a socket for reading and writing |
|
44 @param aInfo connection information |
|
45 */ |
|
46 CObexActiveReader::CObexActiveReader (MObexTransportNotify& aOwner, RSocket& aSocket, TObexConnectionInfo& aInfo) |
|
47 : CObexReaderBase (EPriorityStandard, aOwner, aInfo), |
|
48 iSocket(aSocket) |
|
49 { |
|
50 LOG_LINE |
|
51 LOG_FUNC |
|
52 } |
|
53 |
|
54 /** |
|
55 Destructor |
|
56 */ |
|
57 EXPORT_C CObexActiveReader::~CObexActiveReader () |
|
58 { |
|
59 LOG_LINE |
|
60 LOG_FUNC |
|
61 |
|
62 Cancel (); |
|
63 } |
|
64 |
|
65 /** |
|
66 Called to actually transfer some data into iLocation |
|
67 */ |
|
68 void CObexActiveReader::DoTransfer () |
|
69 { |
|
70 LOG_FUNC |
|
71 |
|
72 iSocket.Recv(iLocation, KSockReadContinuation, iStatus); |
|
73 SetActive (); |
|
74 } |
|
75 |
|
76 /** |
|
77 Return the maximum packet size |
|
78 @return TInt the maximum packet size for this transport |
|
79 */ |
|
80 TInt CObexActiveReader::GetMaxPacketSize() |
|
81 { |
|
82 LOG_FUNC |
|
83 |
|
84 // Some slightly dubious logic here... |
|
85 // IrDA has a degenerate case when running over a 256 byte transport layer link, we claim |
|
86 // to support <255 bytes. The Obex spec says that all stations must be able to handle |
|
87 // 255 bytes, so some stacks may ignore our limit. |
|
88 // Thus we compare against the actual buffer size, rather than what we told the remote end |
|
89 // we could handle, so we *may* be able to handle being sent a few bytes more than expected... |
|
90 |
|
91 TInt ret = GetObexPacketBufferSize(); |
|
92 LOG1(_L8("\tret = %d"), ret); |
|
93 return ret; |
|
94 } |
|
95 |
|
96 /** |
|
97 Returns a initial packet size when the packet size of iPacket is not know. This is used |
|
98 when determining the remaining bytes to be read. |
|
99 @return TInt the initial packet size |
|
100 */ |
|
101 TInt CObexActiveReader::GetInitialPacketSize () |
|
102 { |
|
103 LOG_FUNC |
|
104 |
|
105 return GetObexPacketHeaderSize(); |
|
106 } |
|
107 |
|
108 void CObexActiveReader::DoCancel () |
|
109 { |
|
110 LOG_FUNC |
|
111 |
|
112 iSocket.CancelRecv (); |
|
113 } |
|