|
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 <sipexpiresheader.h> |
|
20 #include <sipmessageelements.h> |
|
21 #include <sipregistrationbinding.h> |
|
22 |
|
23 #include "TCmdUpdateRegistration.h" |
|
24 #include "SIPConstants.h" |
|
25 |
|
26 /** |
|
27 * INPUT: |
|
28 * Headers: Content-Type*, Content-Encoding*, Expires*, Security-Client* |
|
29 * Parameters: Content* |
|
30 * IDs: RegistrationId |
|
31 * |
|
32 * OUTPUT: |
|
33 * Parameters: - |
|
34 * IDs: TransactionId |
|
35 */ |
|
36 void TCmdUpdateRegistration::ExecuteL() |
|
37 { |
|
38 // -- Setup --------------------------------------------------------------- |
|
39 |
|
40 // Get SIP objects from registry |
|
41 CSIPRegistrationBinding* registration = GetRegistrationL(); |
|
42 |
|
43 // Get optional Expires header. It's important to extract the header |
|
44 // as CSIPRegistration::UpdateL() doesn't allow it to be passed as part |
|
45 // of the user headers. |
|
46 CSIPExpiresHeader* expiresHeader = ExtractExpiresHeaderLC( EFalse ); |
|
47 TInt expires( KErrNotFound ); |
|
48 if( expiresHeader ) |
|
49 { |
|
50 expires = expiresHeader->Value(); |
|
51 } |
|
52 |
|
53 // Extract both headers (that are still left) and content. |
|
54 CSIPMessageElements* elements = ExtractHeadersAndContentLC(); |
|
55 |
|
56 // -- Execution ----------------------------------------------------------- |
|
57 |
|
58 // Start registration update, either with or without an Expires value |
|
59 CSIPClientTransaction* transaction; |
|
60 if( expires != KErrNotFound ) |
|
61 { |
|
62 transaction = registration->UpdateL( expires, elements ); |
|
63 } |
|
64 else |
|
65 { |
|
66 transaction = registration->UpdateL( elements ); |
|
67 } |
|
68 |
|
69 CleanupStack::Pop( elements ); |
|
70 if( expiresHeader ) |
|
71 { |
|
72 CleanupStack::Pop( expiresHeader ); |
|
73 } |
|
74 |
|
75 // -- Response creation --------------------------------------------------- |
|
76 |
|
77 AddIdResponseL( KTransactionId, transaction ); |
|
78 } |
|
79 |
|
80 TBool TCmdUpdateRegistration::Match( const TTcIdentifier& aId ) |
|
81 { |
|
82 return TTcSIPCommandBase::Match( aId, _L8("UpdateRegistration") ); |
|
83 } |
|
84 |
|
85 TTcCommandBase* TCmdUpdateRegistration::CreateL( MTcTestContext& aContext ) |
|
86 { |
|
87 return new( ELeave ) TCmdUpdateRegistration( aContext ); |
|
88 } |
|
89 |