|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __P2PROUTERCHANNELIFS_H__ |
|
21 #define __P2PROUTERCHANNELIFS_H__ |
|
22 |
|
23 #include <e32def.h> // For TInt, TAny |
|
24 |
|
25 /* |
|
26 * Abstract interface for router to use channel services. |
|
27 */ |
|
28 class MP2PRouterChIf |
|
29 { |
|
30 |
|
31 public: |
|
32 |
|
33 /* |
|
34 * Closes the connection and interface. |
|
35 * Called in P2P router ext thread context. |
|
36 */ |
|
37 virtual void ConnectionLost() = 0; |
|
38 |
|
39 /* |
|
40 * Enques channel request completing DFC. |
|
41 * Called in P2P router ext thread context. |
|
42 * @param aRequest, request to be completed |
|
43 * @param aStatusToComplete, status to complete to client. |
|
44 */ |
|
45 virtual void EnqueChannelRequestCompleteDfc( TInt aRequest, TInt aStatusToComplete ) = 0; |
|
46 |
|
47 /* |
|
48 * Receive a message from router. |
|
49 * Responsibility to deallocate the message is transferred to channel. |
|
50 * Can be called in 1..N thread contextes. |
|
51 * Cat no be called with FM held. |
|
52 * Same restríctions than in IST API (see from MTrxMuxIf). |
|
53 * @param aMessage, message to receive |
|
54 */ |
|
55 virtual void ReceiveMsg( const TDesC8& aMessage ) = 0; |
|
56 |
|
57 }; |
|
58 |
|
59 /* |
|
60 * Abstract interface for channel to use router services. |
|
61 */ |
|
62 class MP2PChRouterIf |
|
63 { |
|
64 |
|
65 public: |
|
66 |
|
67 // Enumerations for different threads. |
|
68 enum TP2PDfcThread |
|
69 { |
|
70 EP2PDfcThread = 0, |
|
71 EP2PLddDfcThread, |
|
72 EAmountOfP2PDfcThreads |
|
73 }; |
|
74 |
|
75 /* |
|
76 * Informs router that channel is closed. |
|
77 * @param aProtocolId, closing protocol id |
|
78 */ |
|
79 virtual void Close( const TUint8 aProtocolId ) = 0; |
|
80 |
|
81 /* |
|
82 * Return ETrue if the connection is lost. |
|
83 * Called in P2P router ext thread context. |
|
84 */ |
|
85 virtual TBool ConnectionExist( const TUint8 aProtocolId ) = 0; |
|
86 |
|
87 /* |
|
88 * Returns thread according to TP2PDfcThread enums. |
|
89 * @param aThreadIndex, threads index in table |
|
90 * @return pointer to thread |
|
91 */ |
|
92 virtual TDfcQue* GetDfcThread( const TP2PDfcThread aThreadIndex ) = 0; |
|
93 |
|
94 /* |
|
95 * Returns the interface. |
|
96 * @return pointer to the interface |
|
97 */ |
|
98 static MP2PChRouterIf* GetIf(); |
|
99 |
|
100 /* |
|
101 * Informs router that channel is ready to be open. |
|
102 * If transceiver is not found sets the open pending. |
|
103 * Router shall complete the pending opens when transceiver is ready. |
|
104 * @param aProtocolId, channels unique P2P identifier |
|
105 * @param aCallback, pointer to channel interface |
|
106 */ |
|
107 virtual void Open( const TUint8 aProtocolId, MP2PRouterChIf* aCallback ) = 0; |
|
108 |
|
109 /* |
|
110 * Sends a message to router. |
|
111 * Responsibility to deallocate the message is transferred router. |
|
112 * @param aMessage, messages reference |
|
113 * @aProtocolId, channels unique P2P identifier |
|
114 * @return, KErrNone if succesfull, KErrNotReady if transceiver is not present. |
|
115 */ |
|
116 virtual TInt Send( TDes8& aMessage, const TUint8 aProtocolId ) = 0; |
|
117 |
|
118 }; |
|
119 |
|
120 #endif /* __P2PROUTERCHANNELIFS_H__ */ |