33
|
1 |
/*
|
42
|
2 |
* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
33
|
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: Observes Profile state changes.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
42
|
20 |
#include <coreapplicationuissdkcrkeys.h>
|
33
|
21 |
#include "TSatSystemStateFactory.h"
|
|
22 |
#include "MSatSystemStateChangeNotifier.h"
|
|
23 |
#include "MSatUtils.h"
|
|
24 |
#include "csatprofilechangeobserver.h"
|
|
25 |
#include "SatLog.h"
|
|
26 |
#include "CSatSUiClientHandler.h"
|
|
27 |
|
|
28 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
// CSatProfileChangeObserver::CSatProfileChangeObserver
|
|
32 |
// C++ default constructor can NOT contain any code, that
|
|
33 |
// might leave.
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
//
|
|
36 |
CSatProfileChangeObserver::CSatProfileChangeObserver(
|
|
37 |
MSatUtils& aUtils ) :
|
|
38 |
iUtils( aUtils )
|
|
39 |
{
|
|
40 |
}
|
|
41 |
|
|
42 |
// -----------------------------------------------------------------------------
|
|
43 |
// CSatProfileChangeObserver::NewL
|
|
44 |
// Two-phased constructor.
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
CSatProfileChangeObserver* CSatProfileChangeObserver::NewL(
|
|
48 |
MSatUtils& aUtils )
|
|
49 |
{
|
|
50 |
LOG( SIMPLE, "SATENGINE: CSatProfileChangeObserver::NewL calling" )
|
|
51 |
|
|
52 |
CSatProfileChangeObserver* self =
|
|
53 |
new ( ELeave ) CSatProfileChangeObserver( aUtils );
|
|
54 |
CleanupStack::PushL( self );
|
|
55 |
self->ConstructL();
|
|
56 |
CleanupStack::Pop( self );
|
|
57 |
|
|
58 |
LOG( SIMPLE, "SATENGINE: CSatProfileChangeObserver::NewL exiting" )
|
|
59 |
return self;
|
|
60 |
}
|
|
61 |
|
|
62 |
// Destructor
|
|
63 |
CSatProfileChangeObserver::~CSatProfileChangeObserver()
|
|
64 |
{
|
|
65 |
LOG( SIMPLE,
|
|
66 |
"SATENGINE: CSatProfileChangeObserver::~CSatProfileChangeObserver \
|
|
67 |
calling" )
|
|
68 |
|
|
69 |
if ( iStateNotifier )
|
|
70 |
{
|
|
71 |
iStateNotifier->CancelNotify();
|
|
72 |
delete iStateNotifier;
|
|
73 |
iStateNotifier = NULL;
|
|
74 |
}
|
|
75 |
|
|
76 |
LOG( SIMPLE,
|
|
77 |
"SATENGINE: CSatProfileChangeObserver::~CSatProfileChangeObserver \
|
|
78 |
exiting" )
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CSatProfileChangeObserver::ConstructL
|
|
83 |
// Two-phased constructor.
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
void CSatProfileChangeObserver::ConstructL()
|
|
87 |
{
|
|
88 |
LOG( SIMPLE, "SATENGINE: CSatProfileChangeObserver::ConstructL calling" )
|
|
89 |
|
|
90 |
iStateNotifier = TSatSystemStateFactory::CreateProfileChangeNotifierL( *this );
|
|
91 |
// Start observer immediately
|
|
92 |
iStateNotifier->NotifyChangeL();
|
|
93 |
|
|
94 |
// iPreviousProfile must set to -1 because values 0-49
|
|
95 |
// are reserved for different profiles.
|
|
96 |
iPreviousProfile = -1;
|
|
97 |
|
|
98 |
LOG( SIMPLE, "SATENGINE: CSatSAPChangeObserver::ConstructL exiting" )
|
|
99 |
}
|
|
100 |
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
// CSatProfileChangeObserver::StateChanged
|
|
103 |
// Two-phased constructor.
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CSatProfileChangeObserver::StateChanged( const TInt aValue )
|
|
107 |
{
|
|
108 |
LOG2( SIMPLE, "SATENGINE: CSatProfileChangeObserver::StateChanged calling \
|
|
109 |
with value %d", aValue )
|
|
110 |
|
|
111 |
// If profile is off-line send removing event
|
42
|
112 |
if ( ECoreAppUIsNetworkConnectionNotAllowed == aValue )
|
33
|
113 |
{
|
|
114 |
LOG( SIMPLE, "SATENGINE: Off-line" )
|
|
115 |
// Off-line state activated.
|
|
116 |
// Notify listeners about SAT UI icon removing
|
|
117 |
iUtils.NotifyEvent( MSatUtils::ERemoveSatUiCalled );
|
|
118 |
}
|
|
119 |
|
|
120 |
// Send event if previous state was offline.
|
|
121 |
// The event will not be sent in following case: Phone is started
|
|
122 |
// in offline mode and profile is changed to online. Proactive
|
|
123 |
// SetupMenu command is received from SIM card not before phone is
|
|
124 |
// in online mode. iPreviousProfile is -1 when StateChanged is called
|
|
125 |
// first time.
|
42
|
126 |
else if ( ( ECoreAppUIsNetworkConnectionNotAllowed != aValue ) &&
|
|
127 |
( ECoreAppUIsNetworkConnectionNotAllowed == iPreviousProfile ) )
|
33
|
128 |
{
|
|
129 |
LOG( SIMPLE, "SATENGINE: !Off-line" )
|
|
130 |
// Notify listeners about SAT UI icon adding
|
|
131 |
iUtils.NotifyEvent( MSatUtils::EAddSatUiCalled );
|
|
132 |
}
|
|
133 |
|
|
134 |
else
|
|
135 |
{
|
|
136 |
// meaningless else. Only for Lint
|
|
137 |
}
|
|
138 |
|
|
139 |
iPreviousProfile = aValue;
|
|
140 |
|
|
141 |
LOG( SIMPLE, "SATENGINE: CSatProfileChangeObserver::StateChanged exiting" )
|
|
142 |
}
|
|
143 |
|
|
144 |
// End of file
|