|
1 // Copyright (c) 2005-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 // Name : CSIPClientDiscoveryImpl.cpp |
|
15 // Part of : SIP Client Resolver |
|
16 // Version : 1.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDES |
|
22 #include <s32mem.h> |
|
23 #include "CSIPClientDiscoveryImpl.h" |
|
24 #include "CSipCRServer.h" |
|
25 #include "CSIPClientDiscoverySerializer.h" |
|
26 #include "CSIPClientDiscoveryReceiver.h" |
|
27 #include "sipclientdiscoveryobserver.h" |
|
28 #include "sipstrings.h" |
|
29 #include "siprequest.h" |
|
30 #include "uricontainer.h" |
|
31 |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS ============================== |
|
34 |
|
35 // ---------------------------------------------------------------------------- |
|
36 // CSIPClientDiscoveryImpl::NewL |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 CSIPClientDiscoveryImpl* CSIPClientDiscoveryImpl::NewL ( |
|
40 MSIPClientDiscoveryObserver& aObserver, |
|
41 TUid aSelf) |
|
42 { |
|
43 CSIPClientDiscoveryImpl* self = CSIPClientDiscoveryImpl::NewLC (aObserver, |
|
44 aSelf); |
|
45 CleanupStack::Pop (self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // CSIPClientDiscoveryImpl::NewLC |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 CSIPClientDiscoveryImpl* CSIPClientDiscoveryImpl::NewLC ( |
|
54 MSIPClientDiscoveryObserver& aObserver, |
|
55 TUid aSelf) |
|
56 { |
|
57 CSIPClientDiscoveryImpl* self = new(ELeave)CSIPClientDiscoveryImpl; |
|
58 CleanupStack::PushL (self); |
|
59 self->ConstructL (aObserver, aSelf); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CSIPClientDiscoveryImpl::ConstructL |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 void CSIPClientDiscoveryImpl::ConstructL ( |
|
68 MSIPClientDiscoveryObserver& aObserver, |
|
69 TUid aSelf) |
|
70 { |
|
71 SIPStrings::OpenL(); |
|
72 |
|
73 User::LeaveIfError(iSipClientDiscovery.Connect(aSelf)); |
|
74 |
|
75 iSerializer = CSIPClientDiscoverySerializer::NewL(); |
|
76 iReceiver = new(ELeave)CSIPClientDiscoveryReceiver(iSipClientDiscovery, |
|
77 aObserver, |
|
78 *iSerializer); |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CSIPClientDiscovery::~CSIPClientDiscovery |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CSIPClientDiscoveryImpl::~CSIPClientDiscoveryImpl() |
|
86 { |
|
87 delete iReceiver; |
|
88 iSipClientDiscovery.Close(); |
|
89 delete iSerializer; |
|
90 SIPStrings::Close(); |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // CSIPClientDiscoveryImpl::RegisterL |
|
95 // ---------------------------------------------------------------------------- |
|
96 // |
|
97 void CSIPClientDiscoveryImpl::RegisterL(TUid aChannel) |
|
98 { |
|
99 TPckgBuf<TUid> clientUidPckg(aChannel); |
|
100 TIpcArgs ipcArgs(TIpcArgs::ENothing); |
|
101 ipcArgs.Set (ESIPCRIpcArgClientUid, &clientUidPckg); |
|
102 User::LeaveIfError(iSipClientDiscovery.Send(ESIPCRIpcRegister,ipcArgs)); |
|
103 } |
|
104 |
|
105 // ---------------------------------------------------------------------------- |
|
106 // CSIPClientDiscoveryImpl::DeregisterClientL |
|
107 // ---------------------------------------------------------------------------- |
|
108 // |
|
109 TInt CSIPClientDiscoveryImpl::Deregister(TUid aChannel) |
|
110 { |
|
111 TPckgBuf<TUid> clientUidPckg(aChannel); |
|
112 TIpcArgs ipcArgs(TIpcArgs::ENothing); |
|
113 ipcArgs.Set (ESIPCRIpcArgClientUid, &clientUidPckg); |
|
114 return iSipClientDiscovery.Send(ESIPCRIpcDeregister,ipcArgs); |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // CSIPClientDiscoveryImpl::ChannelL |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 TUint32 CSIPClientDiscoveryImpl::ChannelL(RStringF aRequestMethod, |
|
122 const TDesC8& aRequestUri, |
|
123 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
124 const TDesC8& aContent, |
|
125 const CSIPContentTypeHeader* aContentType) |
|
126 { |
|
127 TUid uid(TUid::Null()); |
|
128 return ChannelL (uid, aRequestMethod, aRequestUri, aHeaders, |
|
129 aContent, aContentType); |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // CSIPClientDiscoveryImpl::ChannelL |
|
134 // ---------------------------------------------------------------------------- |
|
135 // |
|
136 TUint32 CSIPClientDiscoveryImpl::ChannelL(TUid aResolver, |
|
137 RStringF aRequestMethod, |
|
138 const TDesC8& aRequestUri, |
|
139 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
140 const TDesC8& aContent, |
|
141 const CSIPContentTypeHeader* aContentType) |
|
142 { |
|
143 CSIPRequest* request = |
|
144 CreateRequestLC(aRequestMethod, aRequestUri, aHeaders, aContentType); |
|
145 CBufFlat* buf = iSerializer->ExternalizeSIPRequestL(*request); |
|
146 CleanupStack::PopAndDestroy(request); |
|
147 CleanupStack::PushL(buf); |
|
148 |
|
149 TPtr8 sipRequest(buf->Ptr(0)); |
|
150 TIpcArgs args(TIpcArgs::ENothing); |
|
151 args.Set(ESIPCRIpcArgSipRequest, &sipRequest); |
|
152 args.Set(ESIPCRIpcArgSipMessageContent, &aContent); |
|
153 |
|
154 TPckgBuf<TUint32> reqIdPckg; |
|
155 args.Set(ESIPCRIpcArgReqId, &reqIdPckg); |
|
156 |
|
157 TInt err = KErrNone; |
|
158 if (aResolver.iUid) |
|
159 { |
|
160 TPckgBuf<TUid> resolverUidPckg(aResolver); |
|
161 args.Set(ESIPCRIpcArgResolverUid, &resolverUidPckg); |
|
162 err = iSipClientDiscovery.SendReceive(ESIPCRIpcChannelWithResolver, |
|
163 args); |
|
164 } |
|
165 else |
|
166 { |
|
167 err = iSipClientDiscovery.SendReceive(ESIPCRIpcChannel, args); |
|
168 } |
|
169 if (err != KErrNone) |
|
170 { |
|
171 User::Leave(err); |
|
172 } |
|
173 |
|
174 CleanupStack::PopAndDestroy(buf); |
|
175 return reqIdPckg(); |
|
176 } |
|
177 |
|
178 // ---------------------------------------------------------------------------- |
|
179 // CSIPClientDiscoveryImpl::Cancel |
|
180 // ---------------------------------------------------------------------------- |
|
181 // |
|
182 void CSIPClientDiscoveryImpl::Cancel(TUint32 aRequestId) |
|
183 { |
|
184 TPckgBuf<TUint32> requestIdPckg(aRequestId); |
|
185 TIpcArgs ipcArgs; |
|
186 ipcArgs.Set (ESIPCRIpcArgReqId, &requestIdPckg); |
|
187 iSipClientDiscovery.Send(ESIPCRIpcCancelRequest, ipcArgs); |
|
188 } |
|
189 |
|
190 // ---------------------------------------------------------------------------- |
|
191 // CSIPClientDiscoveryImpl::CancelAll |
|
192 // ---------------------------------------------------------------------------- |
|
193 // |
|
194 void CSIPClientDiscoveryImpl::CancelAll() |
|
195 { |
|
196 TIpcArgs ipcArgs(TIpcArgs::ENothing); |
|
197 iSipClientDiscovery.Send(ESIPCRIpcCancelAllRequests,ipcArgs); |
|
198 } |
|
199 |
|
200 // ---------------------------------------------------------------------------- |
|
201 // CSIPClientDiscoveryImpl::CreateRequestLC |
|
202 // ---------------------------------------------------------------------------- |
|
203 // |
|
204 CSIPRequest* CSIPClientDiscoveryImpl::CreateRequestLC(RStringF aRequestMethod, |
|
205 const TDesC8& aRequestUri, |
|
206 const RPointerArray<CSIPHeaderBase>& aHeaders, |
|
207 const CSIPContentTypeHeader* aContentType) |
|
208 { |
|
209 CSIPRequest* request = CSIPRequest::NewLC(aRequestMethod); |
|
210 CURIContainer* uriContainer = CURIContainer::DecodeL(aRequestUri); |
|
211 CleanupStack::PushL(uriContainer); |
|
212 request->SetRequestURIL(uriContainer); |
|
213 CleanupStack::Pop(uriContainer); |
|
214 |
|
215 for (TInt i = 0; i<aHeaders.Count(); i++) |
|
216 { |
|
217 request->AddHeaderL(*(aHeaders[i])); |
|
218 } |
|
219 |
|
220 if (aContentType) |
|
221 { |
|
222 request->AddHeaderL((const CSIPHeaderBase&)*aContentType); |
|
223 } |
|
224 |
|
225 return request; |
|
226 } |
|
227 |
|
228 // End of File |