|
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 <sipregistrationbinding.h> |
|
21 #include <siprequestelements.h> |
|
22 #include <siptoheader.h> |
|
23 #include <sipstrings.h> |
|
24 #include <stringpool.h> |
|
25 #include <_sipcodecdefs.h> |
|
26 |
|
27 #include "CTcSIPConnectionContainer.h" |
|
28 #include "TCmdSendMessage.h" |
|
29 #include "SIPConstants.h" |
|
30 |
|
31 /** |
|
32 * INPUT: |
|
33 * Headers: To, From*, Contact*, Content-Type*, Content-Encoding*, P-Preferred-ID* |
|
34 * Parameters: Content*, RemoteURI* |
|
35 * IDs: RegistrationId*, ConnectionId* |
|
36 * |
|
37 * OUTPUT: |
|
38 * Parameters: - |
|
39 * IDs: TransactionId |
|
40 */ |
|
41 void TCmdSendMessage::ExecuteL() |
|
42 { |
|
43 // -- Setup --------------------------------------------------------------- |
|
44 |
|
45 // Select connection; either default or user specified (and existing) |
|
46 CSIPConnection& connection = SelectConnectionL().Connection(); |
|
47 |
|
48 // Get SIP objects from registry |
|
49 CSIPRegistrationBinding* registration = GetRegistrationL( EFalse ); |
|
50 TBool fromHeaderMandatory( ETrue ); |
|
51 if( registration ) |
|
52 { |
|
53 fromHeaderMandatory = EFalse; |
|
54 } |
|
55 |
|
56 // Extract remote URI |
|
57 CUri8* uri = ExtractRemoteURILC(); |
|
58 |
|
59 // Create SIP request elements, giving uri away |
|
60 CSIPRequestElements* reqElements = CSIPRequestElements::NewL( uri ); |
|
61 CleanupStack::Pop( uri ); |
|
62 CleanupStack::PushL( reqElements ); |
|
63 |
|
64 |
|
65 // Modify to RStringF |
|
66 RStringF methodStr = SIPStrings::Pool().OpenFStringL(KMethodMessage); |
|
67 CleanupClosePushL(methodStr); |
|
68 |
|
69 // Set request method to "MESSAGE" |
|
70 reqElements->SetMethodL( methodStr ); |
|
71 |
|
72 // Extract From header (may be either mandatory or optional) |
|
73 CSIPFromHeader* fromHeader = ExtractFromHeaderLC( fromHeaderMandatory ); |
|
74 if( fromHeader ) |
|
75 { |
|
76 reqElements->SetFromHeaderL( fromHeader ); |
|
77 CleanupStack::Pop( fromHeader ); |
|
78 } |
|
79 |
|
80 // Extract To header |
|
81 CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse ); |
|
82 if( toHeader ) |
|
83 { |
|
84 reqElements->SetToHeaderL( toHeader ); |
|
85 CleanupStack::Pop( toHeader ); |
|
86 } |
|
87 |
|
88 // Extract both headers (that are still left) and content. |
|
89 ExtractHeadersAndContentL( reqElements->MessageElements() ); |
|
90 |
|
91 // -- Execution ----------------------------------------------------------- |
|
92 |
|
93 // Start SIP Request transaction. |
|
94 CSIPClientTransaction* transaction; |
|
95 if( registration ) |
|
96 { |
|
97 transaction = connection.SendRequestL( reqElements, *registration ); |
|
98 } |
|
99 else |
|
100 { |
|
101 transaction = connection.SendRequestL( reqElements ); |
|
102 } |
|
103 |
|
104 CleanupStack::PopAndDestroy(); // methodStr |
|
105 CleanupStack::Pop( reqElements ); |
|
106 |
|
107 // -- Response creation --------------------------------------------------- |
|
108 |
|
109 AddIdResponseL( KTransactionId, transaction ); |
|
110 } |
|
111 |
|
112 TBool TCmdSendMessage::Match( const TTcIdentifier& aId ) |
|
113 { |
|
114 return TTcSIPCommandBase::Match( aId, _L8("SendMessage") ); |
|
115 } |
|
116 |
|
117 TTcCommandBase* TCmdSendMessage::CreateL( MTcTestContext& aContext ) |
|
118 { |
|
119 return new( ELeave ) TCmdSendMessage( aContext ); |
|
120 } |
|
121 |