|
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 <sipregistrationbinding.h> |
|
23 #include <sipsubscribedialogassoc.h> |
|
24 #include <siptoheader.h> |
|
25 #include <sipdialog.h> |
|
26 |
|
27 #include "CTcSIPConnectionContainer.h" |
|
28 #include "TCmdSendSubscribe.h" |
|
29 #include "SIPConstants.h" |
|
30 |
|
31 /** |
|
32 * INPUT: |
|
33 * Headers: From, To*, Contact*, Content-Type*, Content-Encoding*, |
|
34 * Accept*, Event*, Route*, Expires* |
|
35 * Parameters: Content*, RemoteURI*, Refresh* |
|
36 * IDs: RegistrationId* |
|
37 * |
|
38 * OUTPUT: |
|
39 * Parameters: - |
|
40 * IDs: TransactionId, SubscribeDialogId |
|
41 */ |
|
42 void TCmdSendSubscribe::ExecuteL() |
|
43 { |
|
44 // -- Setup --------------------------------------------------------------- |
|
45 |
|
46 // Select connection; either default or user specified (and existing) |
|
47 CSIPConnection& connection = SelectConnectionL().Connection(); |
|
48 |
|
49 // Get SIP objects from registry |
|
50 CSIPRegistrationBinding* registration = GetRegistrationL( EFalse ); |
|
51 TBool fromHeaderMandatory( ETrue ); |
|
52 if( registration ) |
|
53 { |
|
54 fromHeaderMandatory = EFalse; |
|
55 } |
|
56 |
|
57 // Extract required headers (From may be either mandatory or optional) |
|
58 CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse ); |
|
59 CSIPFromHeader* fromHeader = ExtractFromHeaderLC( fromHeaderMandatory ); |
|
60 CSIPEventHeader* eventHeader = ExtractEventHeaderLC(); |
|
61 |
|
62 // Extract optional headers |
|
63 CSIPContactHeader* contactHeader = ExtractContactHeaderLC( EFalse ); |
|
64 |
|
65 // Conditionally create remote URI |
|
66 CUri8* remoteUri = ExtractRemoteURILC(); |
|
67 |
|
68 // Construct the dialog object |
|
69 CSIPSubscribeDialogAssoc* dialogAssoc; |
|
70 |
|
71 if( registration ) |
|
72 { |
|
73 dialogAssoc = CSIPSubscribeDialogAssoc::NewL( |
|
74 connection, remoteUri, *registration, |
|
75 eventHeader, fromHeader, toHeader, contactHeader ); |
|
76 } |
|
77 else |
|
78 { |
|
79 dialogAssoc = CSIPSubscribeDialogAssoc::NewL( |
|
80 connection, fromHeader, remoteUri, |
|
81 eventHeader, toHeader, contactHeader ); |
|
82 } |
|
83 |
|
84 // Purge items from cleanup stack, now they are owned by CSIPInviteDialogAssoc |
|
85 // Some items are optional (i.e. NULL), so we've been tracking the number |
|
86 // of items in pushed to CleanupStack |
|
87 CleanupStack::Pop( iPushed ); |
|
88 iPushed = 0; |
|
89 |
|
90 CleanupStack::PushL( dialogAssoc ); |
|
91 |
|
92 // Conditionally create refresh object |
|
93 CSIPRefresh* refresh = ExtractRefreshLC(); |
|
94 |
|
95 // Extract both headers (that are still left) and content. |
|
96 CSIPMessageElements* elements = ExtractHeadersAndContentLC(); |
|
97 |
|
98 // -- Execution ----------------------------------------------------------- |
|
99 |
|
100 // Start SIP Subscribe transaction. |
|
101 CSIPClientTransaction* transaction = |
|
102 dialogAssoc->SendSubscribeL( elements, refresh ); |
|
103 CleanupStack::Pop( elements ); |
|
104 if( refresh ) |
|
105 { |
|
106 CleanupStack::Pop( refresh ); |
|
107 } |
|
108 |
|
109 // -- Response creation --------------------------------------------------- |
|
110 |
|
111 AddIdResponseL( KTransactionId, transaction ); |
|
112 AddIdResponseL( KDialogId, dialogAssoc->Dialog() ); |
|
113 CleanupStack::Pop( dialogAssoc ); |
|
114 AddIdResponseL( KSubscribeDialogId, dialogAssoc ); |
|
115 } |
|
116 |
|
117 TBool TCmdSendSubscribe::Match( const TTcIdentifier& aId ) |
|
118 { |
|
119 return TTcSIPCommandBase::Match( aId, _L8("SendSubscribe") ); |
|
120 } |
|
121 |
|
122 TTcCommandBase* TCmdSendSubscribe::CreateL( MTcTestContext& aContext ) |
|
123 { |
|
124 return new( ELeave ) TCmdSendSubscribe( aContext ); |
|
125 } |
|
126 |