|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : csipunregistering.cpp |
|
15 // Part of : SIP Registration |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "csipunregistering.h" |
|
22 #include "CSIPRegistrar.h" |
|
23 #include "SipAssert.h" |
|
24 #include "sipcontactheader.h" |
|
25 #include "sipresponse.h" |
|
26 #include "MRegistrationOwner.h" |
|
27 #include "siprequest.h" |
|
28 #include "sipstrings.h" |
|
29 #include "sipstrconsts.h" |
|
30 |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CSIPUnregistering::NewL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CSIPUnregistering* CSIPUnregistering::NewL(MRegistrationContext& aRegistration) |
|
37 { |
|
38 CSIPUnregistering* self = CSIPUnregistering::NewLC(aRegistration); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CSIPUnregistering::NewLC |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CSIPUnregistering* CSIPUnregistering::NewLC(MRegistrationContext& aRegistration) |
|
48 { |
|
49 CSIPUnregistering* self = new (ELeave) CSIPUnregistering(aRegistration); |
|
50 CleanupStack::PushL(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSIPUnregistering::NewLC |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 void CSIPUnregistering::SetNeighbourStates( |
|
59 CSIPRegistrationState* aUnregistered) |
|
60 { |
|
61 __SIP_ASSERT_RETURN(aUnregistered, KErrArgument); |
|
62 |
|
63 iUnregistered = aUnregistered; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSIPUnregistering::~CSIPUnregistering |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CSIPUnregistering::~CSIPUnregistering() |
|
71 { |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CSIPUnregistering::UnregisterL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CSIPUnregistering::UnregisterL(TTransactionId& aTransactionId, |
|
79 CSIPRequest* aRequest) |
|
80 { |
|
81 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
82 |
|
83 CSIPContactHeader* contact = static_cast<CSIPContactHeader*>( |
|
84 aRequest->Header(SIPStrings::StringF(SipStrConsts::EContactHeader),0)); |
|
85 |
|
86 __SIP_ASSERT_LEAVE(contact->ExpiresParameter() == 0, KErrArgument); |
|
87 |
|
88 // registrar must not be NULL after registering succeed. |
|
89 __SIP_ASSERT_LEAVE(iRegistration.Registrar(), KErrGeneral); |
|
90 |
|
91 // copy CallId and CSeq header from binding's registrar to request. |
|
92 iRegistration.Registrar()->FillCallIdAndCSeqL(*aRequest); |
|
93 // update registration expires parameter from aRequest Contact header |
|
94 iRegistration.SetExpiresValueL(*aRequest); |
|
95 // copy To and From header from registration binding to request |
|
96 iRegistration.FillToFromL(*aRequest); |
|
97 |
|
98 iRegistration.UnregisterL(aTransactionId, aRequest); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CSIPUnregistering::ReceiveL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CSIPUnregistering::ReceiveL(TTransactionId aTransactionId, |
|
106 CSIPResponse* aResponse) |
|
107 { |
|
108 __SIP_ASSERT_LEAVE(aResponse, KErrArgument); |
|
109 // the expires parameter value must be 0, other wise panic in debug |
|
110 // mode, leaves in release mode. |
|
111 __SIP_ASSERT_LEAVE(iRegistration.Contact().ExpiresParameter() == 0, |
|
112 KErrGeneral); |
|
113 |
|
114 if (aResponse->Type() == CSIPResponse::E1XX) |
|
115 { |
|
116 // pass provisional response to owner. |
|
117 PassResponseToOwnerL(aResponse, aTransactionId, |
|
118 iRegistration.RegistrationId()); |
|
119 } |
|
120 else |
|
121 { |
|
122 // any final response (response code start from 200-) |
|
123 // will terminate the binding. so this function is |
|
124 // called in order to remove the binding. |
|
125 iRegistration.ReceivedErrorResponseL(); |
|
126 PassResponseToOwnerL(aResponse, aTransactionId, |
|
127 iRegistration.RegistrationId()); |
|
128 iRegistration.SelfDetach(ETrue); |
|
129 iRegistration.ChangeState(iUnregistered); |
|
130 } |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CSIPUnregistering::TransactionEnded |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CSIPUnregistering::TransactionEnded(TTransactionId aTransactionId, |
|
138 TInt aReason) |
|
139 { |
|
140 if (aReason != KErrNone) |
|
141 { |
|
142 iRegistration.ChangeState(iUnregistered); |
|
143 } |
|
144 // pass error to owner. |
|
145 return (PassErrorToOwner(aReason, aTransactionId, |
|
146 iRegistration.RegistrationId())); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CSIPUnregistering::CSIPUnregistering |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 CSIPUnregistering::CSIPUnregistering(MRegistrationContext& aRegistration) |
|
154 : CSIPRegistrationState (aRegistration) |
|
155 { |
|
156 } |