|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: See class definition below. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CTCBEARER_H__ |
|
19 #define __CTCBEARER_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <e32base.h> |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 class MTcBearerFactory; |
|
26 class MTcBearerManager; |
|
27 class MTcBearerObserver; |
|
28 class TInetAddr; |
|
29 |
|
30 // CLASS DEFINITION |
|
31 /** |
|
32 * CTcBearer acts as a façade to the rest of the connection services. |
|
33 * This is the only exported class in the module (in addition to the factories, |
|
34 * of course). The factory classes are used to select a bearer and this class |
|
35 * is then responsible for providing the connection services through |
|
36 * a bearer-independent interface. |
|
37 */ |
|
38 class CTcBearer |
|
39 : public CBase |
|
40 { |
|
41 public: // Constructors and destructor |
|
42 |
|
43 /** |
|
44 * Static constructor. |
|
45 * |
|
46 * @param aFactory Specifies the used bearer type |
|
47 * @return An initialized instance of this class |
|
48 */ |
|
49 IMPORT_C static CTcBearer* NewL( const MTcBearerFactory& aFactory ); |
|
50 |
|
51 /// Destructor |
|
52 IMPORT_C ~CTcBearer(); |
|
53 |
|
54 private: // Constructors |
|
55 |
|
56 /// Default constructor |
|
57 CTcBearer(); |
|
58 |
|
59 /** |
|
60 * 2nd phase constructor. |
|
61 * |
|
62 * @param aFactory Specifies the used bearer type |
|
63 */ |
|
64 void ConstructL( const MTcBearerFactory& aFactory ); |
|
65 |
|
66 public: // New methods |
|
67 |
|
68 /// Initialize port and start waiting for incoming connections |
|
69 IMPORT_C void ConnectL( TInetAddr* aRemoteAddr = NULL ); |
|
70 |
|
71 /// Shut down port and stop waiting for incoming connections |
|
72 IMPORT_C void Close(); |
|
73 |
|
74 /** |
|
75 * Send a block of data contained in aDes |
|
76 * |
|
77 * @param aDes Data to be sent |
|
78 * @exceptions Panics with KErrNotReady if not connected, and with |
|
79 * KErrInUse if we were already sending or receiving. |
|
80 */ |
|
81 IMPORT_C void Send( const TDesC8& aDes ); |
|
82 |
|
83 /** |
|
84 * Receive a block of data to aDes. Completes when aDes is full. |
|
85 * |
|
86 * @param aDes Buffer for incoming data |
|
87 * @exceptions Panics with KErrNotReady if not connected, and with |
|
88 * KErrInUse if we were already sending or receiving. |
|
89 */ |
|
90 IMPORT_C void Receive( TDes8& aDes ); |
|
91 |
|
92 /** |
|
93 * Receive a block of data to aDes. Completes when at least one |
|
94 * character (byte) has been received. Length of aDes is changed |
|
95 * to reflect the amount of bytes received. |
|
96 * |
|
97 * @param aDes Buffer for incoming data |
|
98 * @exceptions Panics with KErrNotReady if not connected, and with |
|
99 * KErrInUse if we were already sending or receiving. |
|
100 */ |
|
101 IMPORT_C void ReceiveOneOrMore( TDes8& aDes ); |
|
102 |
|
103 /** |
|
104 * Set connection event observer. Use NULL to deregister. |
|
105 * |
|
106 * @param aObserver Pointer to observer object or NULL. |
|
107 */ |
|
108 IMPORT_C void SetObserver( MTcBearerObserver* aObserver ); |
|
109 |
|
110 /** |
|
111 * Retrieves the bearer specific local address and formats |
|
112 * it into human readable form. |
|
113 * |
|
114 * @param aDes Buffer for formatted local address. |
|
115 */ |
|
116 IMPORT_C void GetLocalAddressL( TDes& aDes ); |
|
117 |
|
118 private: // Data |
|
119 |
|
120 /// Pointer to a bearer manager implementation. Owned. |
|
121 MTcBearerManager* iManager; |
|
122 |
|
123 }; |
|
124 |
|
125 #endif // __CTCBEARER_H__ |