|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: conntest application |
|
15 * |
|
16 */ |
|
17 |
|
18 /** |
|
19 @file alractiveobject.cpp |
|
20 ALR application active object. |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <e32cons.h> |
|
25 #include <comms-infras/mobilitymessagesecom.h> |
|
26 #include <mobilitymessages.h> |
|
27 #include "alractiveobject.h" |
|
28 #include "uinotify.h" |
|
29 |
|
30 using namespace ESock; |
|
31 |
|
32 const TInt KCommsMobilityMaxMsgLength = 256; //Max mobility message size is much less than that |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CALRActiveObject::NewL |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CALRActiveObject* CALRActiveObject::NewL( |
|
41 MUINotify& aConsole, |
|
42 MMobilityProtocolResp* aApplication) |
|
43 { |
|
44 CALRActiveObject* self = |
|
45 new ( ELeave ) CALRActiveObject(aConsole, aApplication); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(aConsole); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CALRActiveObject::ConstructL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CALRActiveObject::ConstructL(MUINotify& /*aConsole*/) |
|
57 { |
|
58 iResponseBuf.CreateL( KCommsMobilityMaxMsgLength ); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CALRActiveObject::CALRActiveObject |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CALRActiveObject::CALRActiveObject(MUINotify& aConsole, MMobilityProtocolResp* aApplication ) |
|
66 : CActive( CActive::EPriorityStandard ), |
|
67 iConsole(aConsole), iApplication(aApplication) |
|
68 { |
|
69 CActiveScheduler::Add( this ); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CALRActiveObject::~CALRActiveObject |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CALRActiveObject::~CALRActiveObject() |
|
77 { |
|
78 Cancel(); |
|
79 iExtApi.Close(); |
|
80 iResponseBuf.Close(); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CALRActiveObject::OpenL |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CALRActiveObject::OpenL( RCommsSubSession& aExtensionProvider ) |
|
88 { |
|
89 User::LeaveIfError( iExtApi.Open( aExtensionProvider ) ); |
|
90 |
|
91 //iConsole.PrintNotify(_L("\r\nRegister for mobility notification ")); |
|
92 |
|
93 iExtApi.RegisterForMobilityNotification( iResponseBuf, iStatus ); |
|
94 |
|
95 //iConsole.PrintNotify(_L("\r\nRegistration successful ")); |
|
96 |
|
97 SetActive(); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CALRActiveObject::MigrateToPreferredCarrier |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CALRActiveObject::MigrateToPreferredCarrier() |
|
105 { |
|
106 iExtApi.MigrateToPreferredCarrier(); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CALRActiveObject::IgnorePreferredCarrier |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CALRActiveObject::IgnorePreferredCarrier() |
|
114 { |
|
115 iExtApi.IgnorePreferredCarrier(); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CALRActiveObject::NewCarrierAccepted |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CALRActiveObject::NewCarrierAccepted() |
|
123 { |
|
124 iExtApi.NewCarrierAccepted(); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CALRActiveObject::NewCarrierRejected |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CALRActiveObject::NewCarrierRejected() |
|
132 { |
|
133 iExtApi.NewCarrierRejected(); |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CALRActiveObject::RunL |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CALRActiveObject::RunL() |
|
141 { |
|
142 if( iStatus != KErrNone ) |
|
143 { |
|
144 // iConsole.Printf(_L("\niStatus: %i\n"), iStatus.Int() ); |
|
145 iApplication->Error( iStatus.Int() ); |
|
146 // virtual void Error(TInt aError) = 0; |
|
147 |
|
148 return; |
|
149 } |
|
150 |
|
151 //iConsole.PrintNotify(_L("\r\nReceived notification")); |
|
152 CCommsApiExtensionMsg* msg = CCommsApiExtensionMsg::NewL( iResponseBuf ); |
|
153 |
|
154 //check types |
|
155 STypeId preferredCarrierAvailableTID = STypeId::CreateSTypeId( ESock::KMobilityMessagesImplementationUid, ESock::EPreferredCarrierAvailable ); |
|
156 STypeId newCarrierActiveTID = STypeId::CreateSTypeId( ESock::KMobilityMessagesImplementationUid, ESock::ENewCarrierActive ); |
|
157 |
|
158 if (msg->IsTypeOf(preferredCarrierAvailableTID)) |
|
159 { |
|
160 CPreferredCarrierAvailable& pca = reinterpret_cast<CPreferredCarrierAvailable&>( *msg ); |
|
161 iApplication->PreferredCarrierAvailable( pca.OldAPInfo(), |
|
162 pca.NewAPInfo(), |
|
163 pca.IsUpgrade(), |
|
164 pca.IsSeamless() ); |
|
165 // virtual void PreferredCarrierAvailable(TAccessPointInfo aOldAP, TAccessPointInfo aNewAP, TBool aIsUpgrade, TBool aIsSeamless) = 0; |
|
166 |
|
167 //MigrateToPreferredCarrier(); |
|
168 } |
|
169 else if (msg->IsTypeOf(newCarrierActiveTID)) |
|
170 { |
|
171 CNewCarrierActive& nca = reinterpret_cast<CNewCarrierActive&>( *msg ); |
|
172 iApplication->NewCarrierActive( nca.NewAPInfo(), nca.IsSeamless() ); |
|
173 // virtual void NewCarrierActive(TAccessPointInfo aNewAP, TBool aIsSeamless) = 0; |
|
174 //NewCarrierAccepted(); |
|
175 } |
|
176 |
|
177 delete msg; |
|
178 |
|
179 iExtApi.RegisterForMobilityNotification( iResponseBuf, iStatus ); |
|
180 |
|
181 SetActive(); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CALRActiveObject::DoCancel |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 void CALRActiveObject::DoCancel() |
|
189 { |
|
190 iExtApi.CancelMobilityNotification(); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CALRActiveObject::RunError |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TInt CALRActiveObject::RunError(TInt aError) |
|
198 { |
|
199 //The notification has not been sent to the client because of KErrNoMemory |
|
200 //We may need to provide an inplace construction for the messages to exclude this possibility. |
|
201 return aError; |
|
202 } |
|
203 |
|
204 // End of File |