|
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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <sipclienttransaction.h> |
|
19 #include <sipconnection.h> |
|
20 #include <sipcontactheader.h> |
|
21 #include <sipfromheader.h> |
|
22 #include <sipmessageelements.h> |
|
23 #include <siprefresh.h> |
|
24 #include <sipregistrationbinding.h> |
|
25 #include <siprouteheader.h> |
|
26 #include <siptoheader.h> |
|
27 |
|
28 #include "CTcSIPConnectionContainer.h" |
|
29 #include "TCmdSendRegister.h" |
|
30 #include "SIPConstants.h" |
|
31 |
|
32 /** |
|
33 * INPUT: |
|
34 * Headers: To, Contact, Route*, From*, Content-Type*, Content-Encoding* |
|
35 * Parameters: Refresh*, RemoteURI*, Content*, Proxy* |
|
36 * IDs: ConnectionId* |
|
37 * |
|
38 * OUTPUT: |
|
39 * Parameters: - |
|
40 * IDs: TransactionId, RegistrationId |
|
41 */ |
|
42 void TCmdSendRegister::ExecuteL() |
|
43 { |
|
44 // -- Setup --------------------------------------------------------------- |
|
45 |
|
46 // Select connection; either default or user specified (and existing) |
|
47 CSIPConnection& connection = SelectConnectionL().Connection(); |
|
48 |
|
49 // Extract required headers |
|
50 CSIPToHeader* toHeader = ExtractToHeaderLC(); |
|
51 CSIPContactHeader* contactHeader = ExtractContactHeaderLC(); |
|
52 |
|
53 // Extract optional headers |
|
54 CSIPFromHeader* fromHeader = ExtractFromHeaderLC( EFalse ); |
|
55 |
|
56 // Conditionally create proxy |
|
57 CSIPRouteHeader* proxy = ExtractProxyLC(); |
|
58 |
|
59 // Conditionally create refresh object |
|
60 CSIPRefresh* refresh = ExtractRefreshLC(); |
|
61 |
|
62 // Conditionally create remote URI |
|
63 CUri8* remoteUri = ExtractRemoteURILC(); |
|
64 |
|
65 // Construct the registration object |
|
66 CSIPRegistrationBinding* registration = |
|
67 CSIPRegistrationBinding::NewL( connection, |
|
68 toHeader, contactHeader, |
|
69 refresh, proxy, remoteUri, fromHeader ); |
|
70 |
|
71 // Purge items from cleanup stack, now they are owned by CSIPRegistration |
|
72 // Some items are optional (i.e. NULL), so we've been tracking the number |
|
73 // of items in pushed to CleanupStack |
|
74 CleanupStack::Pop( iPushed ); |
|
75 iPushed = 0; |
|
76 |
|
77 CleanupStack::PushL( registration ); |
|
78 |
|
79 // Extract rest of headers (that are still left) and content. |
|
80 CSIPMessageElements* elements = ExtractHeadersAndContentLC(); |
|
81 |
|
82 // -- Execution ----------------------------------------------------------- |
|
83 |
|
84 // Start SIP Register transaction. |
|
85 CSIPClientTransaction* transaction = registration->RegisterL( elements ); |
|
86 CleanupStack::Pop( elements ); |
|
87 |
|
88 // -- Response creation --------------------------------------------------- |
|
89 |
|
90 AddIdResponseL( KTransactionId, transaction ); |
|
91 CleanupStack::Pop( registration ); |
|
92 AddIdResponseL( KRegistrationId, registration ); |
|
93 } |
|
94 |
|
95 TBool TCmdSendRegister::Match( const TTcIdentifier& aId ) |
|
96 { |
|
97 return TTcSIPCommandBase::Match( aId, _L8("SendRegister") ); |
|
98 } |
|
99 |
|
100 TTcCommandBase* TCmdSendRegister::CreateL( MTcTestContext& aContext ) |
|
101 { |
|
102 return new( ELeave ) TCmdSendRegister( aContext ); |
|
103 } |
|
104 |