|
1 /* |
|
2 * Copyright (c) 2004-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 "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 * Name : CSipCRServerSession.h |
|
16 * Part of : SIP Client Resolver |
|
17 * Version : 1.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 #ifndef CSIPCRSERVERSESSION_H |
|
28 #define CSIPCRSERVERSESSION_H |
|
29 |
|
30 // INCLUDES |
|
31 #include <e32base.h> |
|
32 #include "_sipcodecdefs.h" |
|
33 #include "TSipClient.h" |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 class CSIPCRServer; |
|
37 class CSIPCRSessionReceiver; |
|
38 class CSIPCRRequestItem; |
|
39 class CSIPRequest; |
|
40 class CSIPResponse; |
|
41 class CSIPCRITCUtility; |
|
42 class CSIPResolvedClient; |
|
43 class CSIPResolvedClient2; |
|
44 class CSipCrWorkerAo; |
|
45 |
|
46 // CLASS DEFINITIONS |
|
47 class CSIPCRServerSession : public CSession2 |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 static CSIPCRServerSession* NewL(CSIPCRServer& aCRServer); |
|
52 static CSIPCRServerSession* NewLC(CSIPCRServer& aCRServer); |
|
53 ~CSIPCRServerSession (); |
|
54 |
|
55 public: // From CSession2 |
|
56 |
|
57 void ServiceL(const RMessage2& aMessage); |
|
58 |
|
59 public: // New functions |
|
60 |
|
61 void WorkerAoRequestCompleted(CSipCrWorkerAo* aWorkerAo); |
|
62 |
|
63 void RoutingEntryAddedL(const TUid& aUid); |
|
64 |
|
65 private: // Second phase constructors |
|
66 |
|
67 CSIPCRServerSession(CSIPCRServer& aCRServer); |
|
68 void ConstructL(); |
|
69 |
|
70 private: // Helper functions |
|
71 |
|
72 void DoServiceL (TInt aFunction, const RMessage2& aMessage); |
|
73 |
|
74 void ChannelWithResolverL(const RMessage2& aMessage); |
|
75 |
|
76 void ChannelL(const RMessage2& aMessage); |
|
77 |
|
78 void RegisterL(const TUid& aChannelUid); |
|
79 |
|
80 void DeregisterL(const TUid& aChannelUid); |
|
81 |
|
82 void SetUIDL(const RMessage2& aMessage); |
|
83 |
|
84 void CancelRequestL(const RMessage2& aMessage); |
|
85 |
|
86 void CancelAllRequests(); |
|
87 |
|
88 void CancelClientReceiveL(); |
|
89 |
|
90 void ClientReadyToReceiveL(const RMessage2& aMessage); |
|
91 |
|
92 void ClientReceiveSipResponseL(const RMessage2& aMessage); |
|
93 |
|
94 CSIPResponse* ResolveClientL(CSIPRequest& aRequest, TSipClient& aUid); |
|
95 |
|
96 void ChannelL(TUint32 aRequestId, |
|
97 CSIPRequest& aRequest, |
|
98 const TSipClient& aClientUid, |
|
99 const TUid& aResolverUid); |
|
100 |
|
101 void ChannelImplementationL(CSipCrWorkerAo& aWorkerAo); |
|
102 |
|
103 void HandleNextPendingRequestL(CSipCrWorkerAo& aWorkerAo); |
|
104 |
|
105 void ChannelUidL( const TSipClient& aClient, |
|
106 TUid& aChannelUid, |
|
107 CSIPRequest* aRequest, |
|
108 CSIPResolvedClient* aResolvedClient ); |
|
109 |
|
110 TUint32 CreateRequestId(); |
|
111 |
|
112 TBool FindUid(const RArray<TSipClient>& aUids, |
|
113 TSipClient& aUid, |
|
114 TBool aRomBased, |
|
115 TBool aConnected); |
|
116 |
|
117 typedef TInt (*ThreadFunctionPtr)(TAny* aPtr); |
|
118 |
|
119 void CreateWorkerThreadL( |
|
120 CSipCrWorkerAo* aWorkerAo, |
|
121 ThreadFunctionPtr aThreadFunctionPtr); |
|
122 |
|
123 static TInt ChannelWorkerThreadFunction(TAny* aPtr); |
|
124 |
|
125 static TInt ConnectWorkerThreadFunction(TAny* aPtr); |
|
126 |
|
127 typedef void |
|
128 (CSIPCRServerSession::*WorkerFunctionPtr)(CSipCrWorkerAo& aWorkerAo); |
|
129 |
|
130 static TInt WorkerThreadFunctionImpl( |
|
131 TAny* aPtr, |
|
132 WorkerFunctionPtr aWorkerFunctionPtr); |
|
133 |
|
134 void CancelConnectL(CSIPCRRequestItem* aRequestItem); |
|
135 |
|
136 template<class T> void AddToRequestQueueL( |
|
137 CSIPCRRequestItem* aRequestItem, |
|
138 T& aResolvedClient); |
|
139 |
|
140 template<class T> TBool ConnectL( |
|
141 CSIPCRRequestItem& aRequestItem, |
|
142 T& aResolvedClient); |
|
143 |
|
144 void ProtectedAddToRequestQueueL(CSIPCRRequestItem* aRequestItem); |
|
145 |
|
146 void ProtectedRemoveFromRequestQueue(CSIPCRRequestItem* aRequestItem); |
|
147 |
|
148 static void RemoveFromRequestQueue(TAny* aCleanupData); |
|
149 |
|
150 private: // Data |
|
151 |
|
152 TUid iClientUid; |
|
153 TBool iClientUidSet; |
|
154 CSIPCRServer& iCRServer; |
|
155 CSIPCRSessionReceiver* iReceiver; |
|
156 RPointerArray<CSIPCRRequestItem> iRequestQueue; |
|
157 TUint32 iRequestIdCounter; |
|
158 RPointerArray<CSipCrWorkerAo> iWorkerAos; |
|
159 RMutex iRequestQueueMutex; |
|
160 |
|
161 private: // For testing purposes |
|
162 |
|
163 UNIT_TEST(CSipCRServerSessionTest) |
|
164 }; |
|
165 |
|
166 #endif // CSIPCRSERVERSESSION_H |
|
167 |
|
168 // End of File |