|
1 /* |
|
2 * Copyright (c) 2007 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: Observer of the GPRS connection status change |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <etelpckt.h> |
|
22 #include <pcktcs.h> // for EPacketNotifyStatusChange in DoCancel |
|
23 #include "csatbipconnectionobserver.h" |
|
24 #include "CSatBIPUtils.h" |
|
25 #include "SatLog.h" |
|
26 |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSatBIPConnectionObserver::CSatBIPConnectionObserver |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CSatBIPConnectionObserver::CSatBIPConnectionObserver( |
|
37 CSatBIPUtils& aBipUtils ) : |
|
38 CActive( EPriorityNormal ), |
|
39 iBipUtils( aBipUtils ) |
|
40 { |
|
41 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::\ |
|
42 CSatBIPConnectionObserver calling" ) |
|
43 CActiveScheduler::Add( this ); |
|
44 // Get current status |
|
45 iBipUtils.PacketService().GetStatus( iConnectionStatus ); |
|
46 // Set last status |
|
47 iPrevConnectionStatus = iConnectionStatus; |
|
48 LOG2( NORMAL, "SATENGINE: CSatBIPConnectionObserver::\ |
|
49 CSatBIPConnectionObserver exiting: %i", iConnectionStatus ) |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSatBIPConnectionObserver::~CSatBIPConnectionObserver |
|
54 // Destructor |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CSatBIPConnectionObserver::~CSatBIPConnectionObserver() |
|
58 { |
|
59 LOG( SIMPLE, |
|
60 "SATENGINE: CSatBIPConnectionObserver::~CSatBIPConnectionObserver \ |
|
61 calling" ) |
|
62 Cancel(); |
|
63 LOG( SIMPLE, |
|
64 "SATENGINE: CSatBIPConnectionObserver::~CSatBIPConnectionObserver \ |
|
65 exiting" ) |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSatBIPConnectionObserver::RunL |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CSatBIPConnectionObserver::RunL() |
|
73 { |
|
74 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::RunL calling" ) |
|
75 |
|
76 const TInt errStatus( iStatus.Int() ); |
|
77 LOG2( SIMPLE, " RunL (%i)", errStatus ) |
|
78 LOG2( SIMPLE, " ConnStatus (%i)", iConnectionStatus ) |
|
79 if ( KErrNone == errStatus ) |
|
80 { |
|
81 //if previous status is active packet data connection and |
|
82 //current status is inactive packet data connection, drop links. |
|
83 if( RPacketService::EStatusActive == iPrevConnectionStatus && |
|
84 ( RPacketService::EStatusAttached == iConnectionStatus || |
|
85 RPacketService::EStatusUnattached == iConnectionStatus )) |
|
86 { |
|
87 LOG( NORMAL, "CSatBIPConnectionObserver::RunL stop UDP link" ) |
|
88 iBipUtils.StopUdpLink(); |
|
89 } |
|
90 |
|
91 // Restart request |
|
92 iPrevConnectionStatus = iConnectionStatus; |
|
93 iBipUtils.PacketService().NotifyStatusChange( iStatus, iConnectionStatus ); |
|
94 SetActive(); |
|
95 } |
|
96 |
|
97 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::RunL exiting" ) |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CSatBIPConnectionObserver::DoCancel |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CSatBIPConnectionObserver::DoCancel() |
|
105 { |
|
106 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::DoCancel calling" ) |
|
107 |
|
108 iBipUtils.PacketService().CancelAsyncRequest( EPacketNotifyStatusChange ); |
|
109 |
|
110 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::DoCancel exiting" ) |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CSatBIPConnectionObserver::StartObserver |
|
115 // Starts to observe connection status |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CSatBIPConnectionObserver::StartObserver() |
|
119 { |
|
120 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::StartObserver calling" ) |
|
121 |
|
122 if ( !IsActive() ) |
|
123 { |
|
124 LOG( SIMPLE, " Activating observer" ) |
|
125 iBipUtils.PacketService().NotifyStatusChange( iStatus, iConnectionStatus ); |
|
126 SetActive(); |
|
127 } |
|
128 |
|
129 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::StartObserver exiting" ) |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CSatBIPConnectionObserver::Status |
|
134 // Returns current connection status |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 RPacketService::TStatus CSatBIPConnectionObserver::Status() const |
|
138 { |
|
139 LOG( NORMAL, "SATENGINE: CSatBIPConnectionObserver::Status \ |
|
140 calling-exiting" ) |
|
141 LOG2( NORMAL, " ConnectionStatus: %i", iConnectionStatus ) |
|
142 return iConnectionStatus; |
|
143 } |
|
144 |
|
145 // End of file |