72
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: CSysApCenRepSilentModeObserver implementation.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "SysApCenRepSilentModeObserver.h"
|
|
21 |
#include "SysApAppUi.h"
|
|
22 |
#include <hbindicatorsymbian.h>
|
|
23 |
|
|
24 |
// ========================== MEMBER FUNCTIONS ================================
|
|
25 |
|
|
26 |
// ----------------------------------------------------------------------------
|
|
27 |
// ----------------------------------------------------------------------------
|
|
28 |
|
|
29 |
CSysApCenRepSilentModeObserver* CSysApCenRepSilentModeObserver::NewL( )
|
|
30 |
{
|
|
31 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::NewL" ) ) );
|
|
32 |
CSysApCenRepSilentModeObserver* self = new ( ELeave ) CSysApCenRepSilentModeObserver( );
|
|
33 |
CleanupStack::PushL( self );
|
|
34 |
self->ConstructL();
|
|
35 |
CleanupStack::Pop(); //self
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
// ----------------------------------------------------------------------------
|
|
40 |
// ----------------------------------------------------------------------------
|
|
41 |
|
|
42 |
CSysApCenRepSilentModeObserver::CSysApCenRepSilentModeObserver( )
|
|
43 |
{
|
|
44 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::CSysApCenRepSilentModeObserver" ) ) );
|
|
45 |
}
|
|
46 |
|
|
47 |
// ----------------------------------------------------------------------------
|
|
48 |
// ----------------------------------------------------------------------------
|
|
49 |
|
|
50 |
CSysApCenRepSilentModeObserver::~CSysApCenRepSilentModeObserver()
|
|
51 |
{
|
|
52 |
TRACES( RDebug::Print( _L("~CSysApCenRepSilentModeObserver") ) );
|
|
53 |
if ( iSilentModeHandler )
|
|
54 |
{
|
|
55 |
iSilentModeHandler->StopListening();
|
|
56 |
}
|
|
57 |
delete iSilentModeHandler;
|
|
58 |
delete iSession;
|
|
59 |
}
|
|
60 |
|
|
61 |
// ----------------------------------------------------------------------------
|
|
62 |
// ----------------------------------------------------------------------------
|
|
63 |
|
|
64 |
void CSysApCenRepSilentModeObserver::ConstructL()
|
|
65 |
{
|
|
66 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::ConstructL: trying CRepository::NewL( KCRUidBluetoothPowerState )") ) );
|
|
67 |
iSession = CRepository::NewL( KCRUidProfileEngine );
|
|
68 |
|
|
69 |
iSilentModeHandler =
|
|
70 |
CCenRepNotifyHandler::NewL( *this,
|
|
71 |
*iSession,
|
|
72 |
CCenRepNotifyHandler::EIntKey,
|
|
73 |
KProEngSilenceMode );
|
|
74 |
iSilentModeHandler->StartListeningL();
|
|
75 |
}
|
|
76 |
|
|
77 |
// ----------------------------------------------------------------------------
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
|
|
80 |
void CSysApCenRepSilentModeObserver::HandleNotifyInt( TUint32 aId, TInt aNewValue )
|
|
81 |
{
|
|
82 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::HandleNotifyInt(), aId=0x%x, aNewValue=%d" ), aId, aNewValue ) );
|
|
83 |
|
|
84 |
SilenceIndicatorL(aNewValue);
|
|
85 |
|
|
86 |
}
|
|
87 |
|
|
88 |
// ----------------------------------------------------------------------------
|
|
89 |
// ----------------------------------------------------------------------------
|
|
90 |
|
|
91 |
void CSysApCenRepSilentModeObserver::HandleNotifyError( TUint32 /* aId */, TInt /* error */, CCenRepNotifyHandler* /* aHandler */ )
|
|
92 |
{
|
|
93 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::HandleNotifyError()" ) ) );
|
|
94 |
}
|
|
95 |
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
// ----------------------------------------------------------------------------
|
|
98 |
|
|
99 |
void CSysApCenRepSilentModeObserver::SilenceIndicatorL(TInt aValue)
|
|
100 |
{
|
|
101 |
TRACES( RDebug::Print( _L(" CSysApCenRepSilentModeObserver::SilenceIndicatorL" )));
|
|
102 |
CHbIndicatorSymbian* indicator = CHbIndicatorSymbian::NewL();
|
|
103 |
CleanupStack::PushL(indicator);
|
|
104 |
_LIT(KSilentmodeindicator,"com.nokia.hb.indicator.controlpanel.cpsilenceindicatorplugin/1.0");
|
|
105 |
|
|
106 |
|
|
107 |
if (aValue)
|
|
108 |
{
|
|
109 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::HandleNotifyInt() activate silence indicator" )));
|
|
110 |
// activate the indicator plugin to display the icon in status bar
|
|
111 |
indicator->Activate(KSilentmodeindicator);
|
|
112 |
}
|
|
113 |
else
|
|
114 |
{
|
|
115 |
TRACES( RDebug::Print( _L("CSysApCenRepSilentModeObserver::HandleNotifyInt() Deactivate silence indicator" )));
|
|
116 |
// deactivate the indicator plugin to remove the icon in the status bar
|
|
117 |
indicator->Deactivate(KSilentmodeindicator);
|
|
118 |
}
|
|
119 |
CleanupStack::PopAndDestroy(indicator); // indicator
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
// End of File
|
|
124 |
|