|
1 // Copyright (c) 2007-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 : sipprflderegisterrequestedstate.cpp |
|
15 // Part of : sip profile fsm |
|
16 // implementation |
|
17 // Version : %version: 2.1.1 % |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprflderegisterrequestedstate.h" |
|
24 #include "sipregistrationbinding.h" |
|
25 #include "sipclienttransaction.h" |
|
26 #include "sipprofileagentobserver.h" |
|
27 #include "sipprofilefsmuser.h" |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CSIPPrflDeregisterRequestedState::NewL() |
|
34 // (other items were commented in a header). |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 EXPORT_C CSIPPrflDeregisterRequestedState* |
|
38 CSIPPrflDeregisterRequestedState::NewL(MSIPProfileFSMUser& aUser) |
|
39 { |
|
40 return new (ELeave) CSIPPrflDeregisterRequestedState(aUser); |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CSIPPrflDeregisterRequestedState::CSIPPrflDeregisterRequestedState() |
|
45 // (other items were commented in a header). |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CSIPPrflDeregisterRequestedState::CSIPPrflDeregisterRequestedState( |
|
49 MSIPProfileFSMUser& aUser) |
|
50 : CSIPPrflStateBase(aUser,MSIPProfileContext::EDeregisterRequested) |
|
51 { |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSIPPrflDeregisterRequestedState::~CSIPPrflDeregisterRequestedState() |
|
56 // (other items were commented in a header). |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CSIPPrflDeregisterRequestedState::~CSIPPrflDeregisterRequestedState() |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CSIPPrflDeregisterRequestedState::LinkStates() |
|
65 // (other items were commented in a header). |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C void CSIPPrflDeregisterRequestedState::LinkStates( |
|
69 CSIPPrflStateBase& aInitState, |
|
70 CSIPPrflStateBase& aRegisteredState, |
|
71 CSIPPrflStateBase& aDeregistrationInProgressState) |
|
72 { |
|
73 iInitState = &aInitState; |
|
74 iRegisteredState = &aRegisteredState; |
|
75 iDeregistrationInProgressState = &aDeregistrationInProgressState; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CSIPPrflDeregisterRequestedState::ConcreteProfileState() |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CSIPConcreteProfile::TStatus |
|
83 CSIPPrflDeregisterRequestedState::ConcreteProfileState() const |
|
84 { |
|
85 return CSIPConcreteProfile::EUnregistrationInProgress; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CSIPPrflDeregisterRequestedState::Deregister() |
|
90 // (other items were commented in a header). |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CSIPPrflDeregisterRequestedState::RegisterL( |
|
94 MSIPProfileContext& aContext) |
|
95 { |
|
96 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
97 aContext.SetNextState(*iRegisteredState); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CSIPPrflDeregisterRequestedState::ErrorOccured() |
|
102 // This can happen if the de-register was reguested while the connection is |
|
103 // suspended (registered->de-register requested). SIP stack has removed |
|
104 // the registration binding, so NOP and transition to Init state. |
|
105 // (other items were commented in a header). |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CSIPPrflDeregisterRequestedState::ErrorOccured( |
|
109 MSIPProfileContext& aContext, |
|
110 TInt aError) |
|
111 { |
|
112 //registration was dropped due to the expired refresh while connection is suspended |
|
113 HandleError(aContext, aError, iInitState); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CSIPPrflDeregisterRequestedState::ConnectionStateChanged() |
|
118 // (other items were commented in a header). |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CSIPPrflDeregisterRequestedState::ConnectionStateChanged( |
|
122 MSIPProfileContext& aContext, |
|
123 CSIPConnection::TState aState) |
|
124 { |
|
125 __ASSERT_DEBUG(aContext.Registration()!=0, User::Invariant()); |
|
126 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
127 switch(aState) |
|
128 { |
|
129 case CSIPConnection::EActive: |
|
130 { |
|
131 aContext.SetNextState(*iRegisteredState); |
|
132 TRAPD(err, iUser.DeregisterProfileL(*aContext.Profile())); |
|
133 if (err) |
|
134 { |
|
135 HandleError(aContext, err, iInitState); |
|
136 } |
|
137 break; |
|
138 } |
|
139 case CSIPConnection::EInactive: |
|
140 { |
|
141 TUint32 contextId(0); |
|
142 CSIPConcreteProfile& profile = DoCleanup(aContext,contextId); |
|
143 aContext.SetNextState(*iInitState); |
|
144 aContext.AgentObserver().SIPProfileStatusEvent(profile,contextId); |
|
145 break; |
|
146 } |
|
147 /* When State EUnavailable is received, the registration Binding in the SIPStack |
|
148 * is no longer present. Hence we have to do the cleanup here and propagate the |
|
149 * error back to clients of profiles. |
|
150 */ |
|
151 case CSIPConnection::EUnavailable: |
|
152 { |
|
153 HandleError(aContext, KErrCouldNotConnect, iInitState); |
|
154 break; |
|
155 } |
|
156 default: |
|
157 break; |
|
158 } |
|
159 |
|
160 } |