|
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 : sipprflresolvingproxiesstate.cpp |
|
15 // Part of : sip profile fsm |
|
16 // implementation |
|
17 // Version : %version: 2.1.1 % |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprflresolvingproxiesstate.h" |
|
24 #include "sipconcreteprofile.h" |
|
25 #include "sipprofileagentobserver.h" |
|
26 #include "sipmessageelements.h" |
|
27 #include "sipregistrationbinding.h" |
|
28 #include "sipclienttransaction.h" |
|
29 #include "sipprflinitstate.h" |
|
30 #include "sipprflregisterrequestedstate.h" |
|
31 #include "sipprflregistrationinprogressstate.h" |
|
32 #include "sipprflregisteredstate.h" |
|
33 #include "sipprflderegistrationinprogressstate.h" |
|
34 #include "sipprflderegisterrequestedstate.h" |
|
35 #include "sipprflstatebase.h" |
|
36 #include "sipprofilefsmuser.h" |
|
37 |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSIPPrflResolvingProxiesState::NewL() |
|
43 // (other items were commented in a header). |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CSIPPrflResolvingProxiesState* CSIPPrflResolvingProxiesState::NewL( |
|
47 MSIPProfileFSMUser& aUser) |
|
48 { |
|
49 return new(ELeave)CSIPPrflResolvingProxiesState(aUser); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSIPPrflResolvingProxiesState::CSIPPrflResolvingProxiesState |
|
54 // (other items were commented in a header). |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CSIPPrflResolvingProxiesState::CSIPPrflResolvingProxiesState( |
|
58 MSIPProfileFSMUser& aUser) |
|
59 : CSIPPrflStateBase(aUser,MSIPProfileContext::EProxyResolvingInProgress) |
|
60 { |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CSIPPrflResolvingProxiesState::CSIPPrflResolvingProxiesState |
|
65 // (other items were commented in a header). |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CSIPPrflResolvingProxiesState::~CSIPPrflResolvingProxiesState() |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CSIPPrflResolvingProxiesState::LinkStates() |
|
74 // (other items were commented in a header). |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C void CSIPPrflResolvingProxiesState::LinkStates( |
|
78 CSIPPrflStateBase& aInitState, |
|
79 CSIPPrflStateBase& aRegisterRequestedState, |
|
80 CSIPPrflStateBase& aRegistrationInProgressState) |
|
81 { |
|
82 iInit = &aInitState; |
|
83 iRegisterRequested = &aRegisterRequestedState; |
|
84 iRegistrationInProgress = &aRegistrationInProgressState; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSIPPrflResolvingProxiesState::ConcreteProfileState() |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CSIPConcreteProfile::TStatus |
|
92 CSIPPrflResolvingProxiesState::ConcreteProfileState() const |
|
93 { |
|
94 return CSIPConcreteProfile::ERegistrationInProgress; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CSIPPrflResolvingProxiesState::DeregisterL() |
|
99 // (other items were commented in a header). |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CSIPPrflResolvingProxiesState::DeregisterL( |
|
103 MSIPProfileContext& aContext) |
|
104 { |
|
105 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
106 |
|
107 CSIPConcreteProfile& profile = *aContext.Profile(); |
|
108 TUint32 contextId = 0; |
|
109 |
|
110 aContext.ForgetProfile(); |
|
111 |
|
112 CSIPRegistrationBinding* regBinding = aContext.Registration(); |
|
113 if ( regBinding ) |
|
114 { |
|
115 contextId = aContext.Registration()->ContextId(); |
|
116 aContext.DestroyRegistration(); |
|
117 } |
|
118 |
|
119 aContext.CancelProxyResolving(); |
|
120 |
|
121 aContext.SetNextState(*iInit); |
|
122 aContext.AgentObserver().SIPProfileStatusEvent(profile,contextId); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CSIPPrflResolvingProxiesState::ConnectionStateChanged() |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CSIPPrflResolvingProxiesState::ConnectionStateChanged( |
|
130 MSIPProfileContext& aContext, |
|
131 CSIPConnection::TState aState) |
|
132 { |
|
133 switch(aState) |
|
134 { |
|
135 case CSIPConnection::EActive: |
|
136 { |
|
137 TRAPD( err, aContext.ResolveProxyL() ); |
|
138 if ( err ) |
|
139 { |
|
140 ProxyResolvingRequestFailed( aContext, err ); |
|
141 } |
|
142 break; |
|
143 } |
|
144 case CSIPConnection::EInactive: |
|
145 { |
|
146 aContext.SetNextState(*iRegisterRequested); |
|
147 break; |
|
148 } |
|
149 case CSIPConnection::EUnavailable: |
|
150 { |
|
151 HandleError(aContext, KErrCouldNotConnect, iInit); |
|
152 break; |
|
153 } |
|
154 default: |
|
155 { |
|
156 break; |
|
157 } |
|
158 } |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CSIPPrflResolvingProxiesState::ProxyResolvingRequestCompleteL() |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CSIPPrflResolvingProxiesState::ProxyResolvingRequestCompleteL( |
|
166 MSIPProfileContext& aContext, |
|
167 MDesC8Array& aProxies) |
|
168 { |
|
169 aContext.SetProxiesL(aProxies); |
|
170 if (aContext.Connection().State() == CSIPConnection::EActive) |
|
171 { |
|
172 aContext.SetNextState(*iInit); |
|
173 iUser.RegisterProfileL(*aContext.Profile()); |
|
174 } |
|
175 else |
|
176 { |
|
177 if (aContext.Connection().State() == CSIPConnection::EUnavailable) |
|
178 { |
|
179 HandleError(aContext, KErrCouldNotConnect, iInit); |
|
180 } |
|
181 else |
|
182 { |
|
183 aContext.SetNextState(*iRegisterRequested); |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CSIPPrflResolvingProxiesState::ProxyResolvingRequestFailed() |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CSIPPrflResolvingProxiesState::ProxyResolvingRequestFailed( |
|
193 MSIPProfileContext& aContext, |
|
194 TInt aError) |
|
195 { |
|
196 aContext.SetNextState(*iInit); |
|
197 aContext.HandleProxyResolvingError(aError); |
|
198 } |