|
0
|
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 __P2PKERNELCHANNEL_H_
|
|
|
21 |
#define __P2PKERNELCHANNEL_H_
|
|
|
22 |
|
|
|
23 |
#include <e32def.h> // For TInt, TAny
|
|
|
24 |
#include <e32cmn.h> // For TDesC8,
|
|
|
25 |
#include <kernel.h> // For TMessageQue;
|
|
|
26 |
#include "p2prouterchannelifs.h" // For MP2PRouterChIf
|
|
|
27 |
|
|
|
28 |
// Forward declarations
|
|
|
29 |
class TDfc;
|
|
|
30 |
class MP2PChRouterIf;
|
|
|
31 |
class TThreadMessage;
|
|
|
32 |
class DMsgQueue;
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
* Kernel side P2P channel.
|
|
|
36 |
*/
|
|
|
37 |
NONSHARABLE_CLASS( DP2PKernelChannel ) : public MP2PRouterChIf
|
|
|
38 |
{
|
|
|
39 |
|
|
|
40 |
public:
|
|
|
41 |
|
|
|
42 |
/*
|
|
|
43 |
* Default constructor
|
|
|
44 |
*/
|
|
|
45 |
DP2PKernelChannel();
|
|
|
46 |
|
|
|
47 |
/*
|
|
|
48 |
* Destructor
|
|
|
49 |
*/
|
|
|
50 |
~DP2PKernelChannel();
|
|
|
51 |
|
|
|
52 |
/*
|
|
|
53 |
* Handles the thread message. Synchronizes the execution
|
|
|
54 |
* from multiple client threads to single thread.
|
|
|
55 |
* @param aMsg, thread message
|
|
|
56 |
* @return, return value of the operation.
|
|
|
57 |
*/
|
|
|
58 |
TInt HandleRequest( TThreadMessage& aMsg );
|
|
|
59 |
|
|
|
60 |
// From MP2PRouterChIf start
|
|
|
61 |
/*
|
|
|
62 |
* See comments from MP2PRouterChIf.
|
|
|
63 |
*/
|
|
|
64 |
void ConnectionLost();
|
|
|
65 |
|
|
|
66 |
/*
|
|
|
67 |
* See comments from MP2PRouterChIf.
|
|
|
68 |
*/
|
|
|
69 |
void EnqueChannelRequestCompleteDfc( TInt aRequest, TInt aStatusToComplete );
|
|
|
70 |
|
|
|
71 |
/*
|
|
|
72 |
* See comments from MP2PRouterChIf.
|
|
|
73 |
*/
|
|
|
74 |
void ReceiveMsg( const TDesC8& aMessage );
|
|
|
75 |
// From MP2PRouterChIf end
|
|
|
76 |
|
|
|
77 |
private:
|
|
|
78 |
|
|
|
79 |
void Close( const TUint8 aP2PProtocolId );
|
|
|
80 |
|
|
|
81 |
void Closing( const TUint8 aP2PProtocolId );
|
|
|
82 |
|
|
|
83 |
static void EmptyRxDfc( TAny* aPtr );
|
|
|
84 |
|
|
|
85 |
/*
|
|
|
86 |
* iKernelChMsgQue callback function in p2p router
|
|
|
87 |
* thread context.
|
|
|
88 |
* @param aPtr, pointer to self
|
|
|
89 |
*/
|
|
|
90 |
static void MsgQDfc( TAny* aPtr );
|
|
|
91 |
|
|
|
92 |
void HandleThreadMsg( TThreadMessage& aMsg );
|
|
|
93 |
|
|
|
94 |
void HandleDfcRequest( TThreadMessage& aMsg );
|
|
|
95 |
|
|
|
96 |
TInt HandleSyncRequest( TThreadMessage& aMsg );
|
|
|
97 |
|
|
|
98 |
void DoCancel( TInt aRequest, TInt aMask );
|
|
|
99 |
|
|
|
100 |
void ResetQueues();
|
|
|
101 |
|
|
|
102 |
/*
|
|
|
103 |
* Internal class for handling requests.
|
|
|
104 |
*/
|
|
|
105 |
NONSHARABLE_CLASS( DP2PKernelAsyncRequests ) : public DBase
|
|
|
106 |
{
|
|
|
107 |
|
|
|
108 |
public:
|
|
|
109 |
|
|
|
110 |
/*
|
|
|
111 |
* Constructor
|
|
|
112 |
* @param aSize, sife of the request list.
|
|
|
113 |
*/
|
|
|
114 |
DP2PKernelAsyncRequests( const TInt aSize );
|
|
|
115 |
|
|
|
116 |
/*
|
|
|
117 |
* Destructor
|
|
|
118 |
*/
|
|
|
119 |
~DP2PKernelAsyncRequests();
|
|
|
120 |
|
|
|
121 |
/*
|
|
|
122 |
* Completes the request if it is pending.
|
|
|
123 |
* Do not call with FM held.
|
|
|
124 |
* @param aRequest, request to complete
|
|
|
125 |
* @param aStatusToComplete, completion status to request to complete
|
|
|
126 |
*/
|
|
|
127 |
void Complete( const TUint aRequest, const TInt aStatusToComplete );
|
|
|
128 |
|
|
|
129 |
/*
|
|
|
130 |
* Check does is the request pending.
|
|
|
131 |
* Do not call with FM held.
|
|
|
132 |
* @param aRequest, request to check
|
|
|
133 |
*/
|
|
|
134 |
TBool IsPending( const TUint aRequest );
|
|
|
135 |
|
|
|
136 |
/*
|
|
|
137 |
* Set the request pending.
|
|
|
138 |
* Do not call with FM held.
|
|
|
139 |
* @param aRequest, request to set pending
|
|
|
140 |
* @param aDfc, pointer to DFC function which is enqued when request is completed
|
|
|
141 |
* @param aStatus, pointer to status which is modified when request is completed
|
|
|
142 |
*/
|
|
|
143 |
void SetPending( const TUint aRequest, TDfc* aDfc, TInt* aStatus );
|
|
|
144 |
|
|
|
145 |
private:
|
|
|
146 |
|
|
|
147 |
// Added convention:
|
|
|
148 |
// Prefix "iSh" means shared member variable
|
|
|
149 |
// Prefix "gSh" means shared global variable
|
|
|
150 |
|
|
|
151 |
// Guarding lock.
|
|
|
152 |
NFastMutex* iRequestLock;
|
|
|
153 |
TDfc** iShDfcFunctionList;
|
|
|
154 |
TInt** iShRequestStatusList;
|
|
|
155 |
|
|
|
156 |
};
|
|
|
157 |
|
|
|
158 |
private:
|
|
|
159 |
|
|
|
160 |
// Protocol id of this channel.
|
|
|
161 |
// Only acccessed from p2p router thread.
|
|
|
162 |
TUint8 iP2PProtocolId;
|
|
|
163 |
// Owned, synhronized internally with fastmutexes
|
|
|
164 |
DMsgQueue* iRx;
|
|
|
165 |
// Owned
|
|
|
166 |
TDfc* iEmptyRxDfc;
|
|
|
167 |
// Not owned, just using
|
|
|
168 |
// Only acccessed from p2p router thread.
|
|
|
169 |
TDes8** iPtrPtrToRxBuf;
|
|
|
170 |
MP2PChRouterIf* iRouterIf;
|
|
|
171 |
TMessageQue iKernelChMsgQue;
|
|
|
172 |
// Synhronized internally with fastmutexes
|
|
|
173 |
DP2PKernelAsyncRequests* iRequests;
|
|
|
174 |
|
|
|
175 |
};
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
#endif /* __P2PKERNELCHANNEL_H_ */
|