|
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 <sipinvitedialogassoc.h> |
|
20 #include <sipmessageelements.h> |
|
21 #include <sipprofile.h> |
|
22 |
|
23 #include "CTcSIPProfileContainer.h" |
|
24 #include "CTcSIPConnectionContainer.h" |
|
25 #include "CTcSIPContext.h" |
|
26 |
|
27 #include "TCmdSendInviteUsingProfile.h" |
|
28 #include "SIPConstants.h" |
|
29 |
|
30 /** |
|
31 * INPUT: |
|
32 * Headers: To*, From*, Contact* |
|
33 * Parameters: RemoteURI |
|
34 * IDs: ProfileId, RegistryId |
|
35 * |
|
36 * OUTPUT: |
|
37 * Parameters: - |
|
38 * IDs: TransactionId, InviteDialogId |
|
39 */ |
|
40 void TCmdSendInviteUsingProfile::ExecuteL() |
|
41 { |
|
42 // -- Setup --------------------------------------------------------------- |
|
43 |
|
44 // Extract required headers (From may be either mandatory or optional) |
|
45 CSIPToHeader* toHeader = ExtractToHeaderLC( EFalse ); |
|
46 CSIPFromHeader* fromHeader = ExtractFromHeaderLC( EFalse ); |
|
47 CSIPContactHeader* contactHeader = ExtractContactHeaderLC( EFalse ); |
|
48 |
|
49 // Extract remote URI |
|
50 CUri8* uri = ExtractRemoteURILC( ETrue ); |
|
51 |
|
52 // Get selected registry |
|
53 CTcSIPProfileContainer& container = SelectProfileL(); |
|
54 |
|
55 // Get profile from the profile registry |
|
56 CSIPProfile& profile = GetProfileL( container ); |
|
57 |
|
58 CSIPConnection* sipConnection = container.ProfileRegistry().ConnectionL( profile ); |
|
59 |
|
60 // Ownership is not really transferred if SIPTester has opened already |
|
61 // CSIPConnection for same IAP as profile is using!! |
|
62 if ( sipConnection != &(iContext.Connection().Connection()) ) |
|
63 { |
|
64 // Have to store because needs longer lifetime than just current ExecuteL |
|
65 iContext.Registry().AddObjectL( sipConnection ); |
|
66 } |
|
67 |
|
68 CSIPInviteDialogAssoc* inviteDialogAssoc = |
|
69 CSIPInviteDialogAssoc::NewL( *sipConnection, |
|
70 uri, |
|
71 profile, |
|
72 fromHeader, |
|
73 toHeader, |
|
74 contactHeader ); |
|
75 |
|
76 CleanupStack::Pop( iPushed ); // toHeader; fromheader, uri |
|
77 iPushed = 0; |
|
78 |
|
79 CleanupStack::PushL( inviteDialogAssoc ); |
|
80 |
|
81 // Extract rest of headers (if provided) |
|
82 CSIPMessageElements* elements = ExtractHeadersAndContentLC(); |
|
83 |
|
84 // -- Execution ----------------------------------------------------------- |
|
85 |
|
86 // Start SIP Invite transaction. |
|
87 CSIPClientTransaction* transaction = inviteDialogAssoc->SendInviteL( elements ); |
|
88 CleanupStack::Pop( elements ); |
|
89 |
|
90 // -- Response creation --------------------------------------------------- |
|
91 |
|
92 AddIdResponseL( KTransactionId, transaction ); |
|
93 AddIdResponseL( KInviteDialogId, inviteDialogAssoc ); |
|
94 |
|
95 CleanupStack::Pop( inviteDialogAssoc ); |
|
96 } |
|
97 |
|
98 TBool TCmdSendInviteUsingProfile::Match( const TTcIdentifier& aId ) |
|
99 { |
|
100 return TTcSIPCommandBase::Match( aId, _L8("SendInviteUsingProfile") ); |
|
101 } |
|
102 |
|
103 TTcCommandBase* TCmdSendInviteUsingProfile::CreateL( MTcTestContext& aContext ) |
|
104 { |
|
105 return new( ELeave ) TCmdSendInviteUsingProfile( aContext ); |
|
106 } |
|
107 |