|
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 : sipprflregisterrequested.cpp |
|
15 // Part of : sip profile fsm |
|
16 // implementation |
|
17 // Version : %version: 2.1.1 % |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprflregisterrequestedstate.h" |
|
24 #include "sipmessageelements.h" |
|
25 #include "sipregistrationbinding.h" |
|
26 #include "sipconnection.h" |
|
27 #include "sipclienttransaction.h" |
|
28 #include "sipprofileagentobserver.h" |
|
29 #include "sipprofilefsmuser.h" |
|
30 |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CSIPPrflRegisterRequestedState::NewL() |
|
36 // (other items were commented in a header). |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 EXPORT_C CSIPPrflRegisterRequestedState* CSIPPrflRegisterRequestedState::NewL( |
|
40 MSIPProfileFSMUser& aUser) |
|
41 { |
|
42 return new (ELeave) CSIPPrflRegisterRequestedState(aUser); |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CSIPPrflRegisterRequestedState::CSIPPrflRegisterRequestedState() |
|
47 // (other items were commented in a header). |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CSIPPrflRegisterRequestedState::CSIPPrflRegisterRequestedState( |
|
51 MSIPProfileFSMUser& aUser) |
|
52 : CSIPPrflStateBase(aUser,MSIPProfileContext::ERegisterRequested) |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CSIPPrflRegisterRequestedState::~CSIPPrflRegisterRequestedState() |
|
58 // (other items were commented in a header). |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CSIPPrflRegisterRequestedState::~CSIPPrflRegisterRequestedState() |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CSIPPrflRegisterRequestedState::LinkStates() |
|
67 // (other items were commented in a header). |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 EXPORT_C void CSIPPrflRegisterRequestedState::LinkStates( |
|
71 CSIPPrflStateBase& aInitState, |
|
72 CSIPPrflStateBase& aResolvingProxiesState, |
|
73 CSIPPrflStateBase& aRegistrationInProgressState) |
|
74 { |
|
75 iInit = &aInitState; |
|
76 iResolvingProxies = &aResolvingProxiesState; |
|
77 iRegistrationInProgress = &aRegistrationInProgressState; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CSIPPrflRegisterRequestedState::ConcreteProfileState() |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CSIPConcreteProfile::TStatus |
|
85 CSIPPrflRegisterRequestedState::ConcreteProfileState() const |
|
86 { |
|
87 return CSIPConcreteProfile::ERegistrationInProgress; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CSIPPrflRegisterRequestedState::DeregisterL() |
|
92 // (other items were commented in a header). |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 void CSIPPrflRegisterRequestedState::DeregisterL( |
|
96 MSIPProfileContext& aContext) |
|
97 { |
|
98 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
99 |
|
100 CSIPConcreteProfile* profile = aContext.Profile(); |
|
101 TUint32 contextId = 0; |
|
102 |
|
103 aContext.ForgetProfile(); |
|
104 |
|
105 CSIPRegistrationBinding* regBinding = aContext.Registration(); |
|
106 if ( regBinding ) |
|
107 { |
|
108 contextId = aContext.Registration()->ContextId(); |
|
109 aContext.DestroyRegistration(); |
|
110 } |
|
111 |
|
112 aContext.SetNextState(*iInit); |
|
113 aContext.AgentObserver().SIPProfileStatusEvent(*profile,contextId); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CSIPPrflRegisterRequestedState::ConnectionStateChanged() |
|
118 // (other items were commented in a header). |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CSIPPrflRegisterRequestedState::ConnectionStateChanged( |
|
122 MSIPProfileContext& aContext, |
|
123 CSIPConnection::TState aState) |
|
124 { |
|
125 TInt err = KErrNone; |
|
126 switch(aState) |
|
127 { |
|
128 case CSIPConnection::EActive: |
|
129 { |
|
130 aContext.SetNextState(*iInit); |
|
131 TRAP(err, iUser.RegisterProfileL(*aContext.Profile())); |
|
132 if (err) |
|
133 { |
|
134 HandleError(aContext, err, iInit); |
|
135 } |
|
136 break; |
|
137 } |
|
138 /* When State EUnavailable is received, the registration Binding in the SIPStack |
|
139 * is no longer present. Hence we have to do the cleanup here and propagate the |
|
140 * error back to clients of profiles. |
|
141 */ |
|
142 case CSIPConnection::EUnavailable: |
|
143 { |
|
144 HandleError(aContext, KErrCouldNotConnect, iInit); |
|
145 break; |
|
146 } |
|
147 default: |
|
148 break; |
|
149 } |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CSIPPrflRegisterRequestedState::RegisterL() |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CSIPPrflRegisterRequestedState::RegisterL( |
|
157 MSIPProfileContext& aContext) |
|
158 { |
|
159 aContext.Connection().RefreshConnection(); |
|
160 } |