|
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 #ifndef __OBEXACTIVERW_H__ |
|
17 #define __OBEXACTIVERW_H__ |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 */ |
|
23 |
|
24 #include <e32def.h> |
|
25 #include <e32base.h> |
|
26 |
|
27 class MObexTransportNotify; |
|
28 struct TObexConnectionInfo; |
|
29 class CObexPacket; |
|
30 |
|
31 /** |
|
32 Base class for a specific transport's active reader and writer classes. |
|
33 The derived classes are responsible for sending and receiving data for their |
|
34 transport. |
|
35 |
|
36 @see CObexReaderBase |
|
37 @see CObexWriterBase |
|
38 */ |
|
39 NONSHARABLE_CLASS(CObexActiveRW) : public CActive |
|
40 { |
|
41 public: |
|
42 CObexActiveRW(TPriority aP, MObexTransportNotify& aOwner, TObexConnectionInfo& aInfo); |
|
43 ~CObexActiveRW(); |
|
44 void Transfer(CObexPacket& aPacket); |
|
45 |
|
46 protected: // functions to be implemented by derived classes |
|
47 /** |
|
48 This method does any required initialisation of data for the transfer, |
|
49 including the received, aPacket, before calling NewRequest. |
|
50 |
|
51 @see Transfer |
|
52 @see NewRequest(CObexPacket& aPacket) |
|
53 @param aPacket The packet to read into or written |
|
54 */ |
|
55 virtual void StartTransfer(CObexPacket& aPacket) =0; //called by non virtual Transfer |
|
56 |
|
57 /** |
|
58 This method issues either a read or write of data over the relevant |
|
59 transport object. This method is called from NewRequest. |
|
60 |
|
61 @see NewRequest |
|
62 */ |
|
63 virtual void DoTransfer () =0; |
|
64 |
|
65 /** |
|
66 This method compares the number of bytes, iCount, read/ written, against |
|
67 the packet size. In the case of a write, ETrue is returned if all the |
|
68 bytes have been written, otherwise EFalse. |
|
69 |
|
70 For reads, check if the header is received and if so assign iPacketSize |
|
71 with the packet size indicated in the header of the received packet. Note |
|
72 that the claimed packet size must be greater than the required obex header |
|
73 size and no more than the maximum packet size this transport handles. |
|
74 |
|
75 @see CObexTransportControllerBase::Process() |
|
76 @return TBool return ETrue if the transfer has completed else EFalse |
|
77 */ |
|
78 virtual TBool CompleteTransfer () =0; // check if packet read/write has completed |
|
79 |
|
80 /** |
|
81 This method is called when a transfer is complete. Any actions associated |
|
82 with completion of a transfer should be performed here, for instance |
|
83 sending the packet to the owner of the reader to be processed. |
|
84 */ |
|
85 virtual void OnCompleteTransfer() =0; // perform action associated with read/write completion |
|
86 |
|
87 /** |
|
88 Return the number bytes left to transfer |
|
89 @return TInt the number of bytes left to be transferred |
|
90 */ |
|
91 virtual TInt Remaining () =0; // how much is left to transfer |
|
92 |
|
93 //function used by derived classes |
|
94 void NewRequest (CObexPacket& aPacket); // start new packet send/receive |
|
95 |
|
96 //RunL for derived classes |
|
97 IMPORT_C void RunL (); |
|
98 |
|
99 // Data |
|
100 protected: |
|
101 /**The owner of the derived reader or writer class. Required at construction.*/ |
|
102 MObexTransportNotify& iOwner; |
|
103 |
|
104 /**The obex packet, received from the owner, that will be sent or written into iLocation.*/ |
|
105 CObexPacket* iPacket; |
|
106 |
|
107 /**A pointer to the iPacket buffer at the point where data is to be written |
|
108 from or read into. The maximum length is the remaining bytes to be read or |
|
109 written. Data is read from this buffer into the transport, or written from |
|
110 the transport into this buffer. */ |
|
111 TPtr8 iLocation; |
|
112 |
|
113 /**The number of bytes that have been read or written*/ |
|
114 TInt iCount; |
|
115 |
|
116 /**The size of the obex packet */ |
|
117 TInt iPacketSize; |
|
118 |
|
119 /**Is true if the transport is a packet based transport*/ |
|
120 TBool iPacketBased; |
|
121 }; |
|
122 |
|
123 #endif // __OBEXACTIVERW_H__ |