|
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 : sipprflinitstate.cpp |
|
15 // Part of : sip profile fsm |
|
16 // implementation |
|
17 // Version : %version: 2.1.1 % |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprflinitstate.h" |
|
24 #include "sipprofileagentobserver.h" |
|
25 #include "sipmessageelements.h" |
|
26 #include "sipregistrationbinding.h" |
|
27 #include "sipclienttransaction.h" |
|
28 #include "sipprflinitstate.h" |
|
29 #include "sipprflregisterrequestedstate.h" |
|
30 #include "sipprflregistrationinprogressstate.h" |
|
31 #include "sipprflregisteredstate.h" |
|
32 #include "sipprflderegistrationinprogressstate.h" |
|
33 #include "sipprflderegisterrequestedstate.h" |
|
34 #include "sipprflstatebase.h" |
|
35 #include "sipprofilefsmuser.h" |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS =============================== |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CSIPPrflInitState::NewL() |
|
41 // (other items were commented in a header). |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CSIPPrflInitState* CSIPPrflInitState::NewL(MSIPProfileFSMUser& aUser) |
|
45 { |
|
46 return new (ELeave) CSIPPrflInitState(aUser); |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CSIPPrflInitState::CSIPPrflInitState |
|
51 // (other items were commented in a header). |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CSIPPrflInitState::CSIPPrflInitState(MSIPProfileFSMUser& aUser) |
|
55 : CSIPPrflStateBase(aUser,MSIPProfileContext::EInit) |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CSIPPrflInitState::CSIPPrflInitState |
|
61 // (other items were commented in a header). |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C CSIPPrflInitState::~CSIPPrflInitState() |
|
65 { |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSIPPrflInitState::LinkStates() |
|
70 // (other items were commented in a header). |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 EXPORT_C void CSIPPrflInitState::LinkStates( |
|
74 CSIPPrflStateBase& aResolvingProxiesState, |
|
75 CSIPPrflStateBase& aRegisterRequestedState, |
|
76 CSIPPrflStateBase& aRegistrationInProgressState) |
|
77 { |
|
78 iResolvingProxies = &aResolvingProxiesState; |
|
79 iRegisterRequested = &aRegisterRequestedState; |
|
80 iRegistrationInProgress = &aRegistrationInProgressState; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CSIPPrflInitState::ConcreteProfileState() |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CSIPConcreteProfile::TStatus CSIPPrflInitState::ConcreteProfileState() const |
|
88 { |
|
89 return CSIPConcreteProfile::EUnregistered; |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CSIPPrflInitState::RegisterL() |
|
94 // (other items were commented in a header). |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CSIPPrflInitState::RegisterL( |
|
98 MSIPProfileContext& aContext) |
|
99 { |
|
100 __ASSERT_ALWAYS( |
|
101 aContext.Connection().State() != CSIPConnection::EUnavailable, |
|
102 User::Leave (KErrCouldNotConnect)); |
|
103 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
104 |
|
105 if (aContext.IsProxyResolvingEnabled() && |
|
106 !aContext.ProxiesAlreadyResolved()) |
|
107 { |
|
108 aContext.ResolveProxyL(); |
|
109 aContext.SetNextState(*iResolvingProxies); |
|
110 } |
|
111 else |
|
112 { |
|
113 if (aContext.Connection().State() == CSIPConnection::EActive) |
|
114 { |
|
115 if (!aContext.Registration()) |
|
116 { |
|
117 aContext.CreateRegistrationL(); |
|
118 } |
|
119 CSIPMessageElements* elems = aContext.CreateMsgElementsLC(); |
|
120 aContext.SetTransaction(aContext.Registration()->RegisterL(elems)); |
|
121 if (elems) |
|
122 { |
|
123 CleanupStack::Pop(elems); |
|
124 } |
|
125 aContext.SetNextState(*iRegistrationInProgress); |
|
126 } |
|
127 else |
|
128 { |
|
129 aContext.SetNextState(*iRegisterRequested); |
|
130 } |
|
131 } |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CSIPPrflInitState::IsIdle |
|
136 // From MSIPProfileFSMUser |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 TBool CSIPPrflInitState::IsIdle( |
|
140 MSIPProfileContext& aContext) |
|
141 { |
|
142 if (!aContext.Profile()) |
|
143 { |
|
144 return ETrue; |
|
145 } |
|
146 return !( iUser.IsInQueue( *aContext.Profile() ) ); |
|
147 } |