29
|
1 |
/*
|
|
2 |
* ============================================================================
|
|
3 |
* Name : btnotifsettingstracker.cpp
|
|
4 |
* Part of : BTProximity / BTProximity
|
|
5 |
* Description : Class for tracking Bluetooth settings, and also for handling notes unrelated to specific connection.
|
|
6 |
*
|
|
7 |
* Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
8 |
* All rights reserved.
|
|
9 |
* This component and the accompanying materials are made available
|
|
10 |
* under the terms of "Eclipse Public License v1.0"
|
|
11 |
* which accompanies this distribution, and is available
|
|
12 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
13 |
*
|
|
14 |
* Initial Contributors:
|
|
15 |
* Nokia Corporation - initial contribution.
|
|
16 |
*
|
|
17 |
* Contributors:
|
|
18 |
* Nokia Corporation
|
|
19 |
* ============================================================================
|
|
20 |
* Template version: 4.1
|
|
21 |
*/
|
|
22 |
|
|
23 |
#include "btnotifsettingstracker.h"
|
|
24 |
#include <btserversdkcrkeys.h>
|
|
25 |
|
|
26 |
#include "btnotifserver.h"
|
|
27 |
#include "btnotificationmanager.h"
|
|
28 |
#include "btnotifclientserver.h"
|
|
29 |
|
|
30 |
|
|
31 |
// ======== MEMBER FUNCTIONS ========
|
|
32 |
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
// C++ default constructor
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
CBTNotifSettingsTracker::CBTNotifSettingsTracker( CBTNotifServer* aServer )
|
|
38 |
: iServer( aServer )
|
|
39 |
{
|
|
40 |
}
|
|
41 |
|
|
42 |
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
// Symbian 2nd-phase constructor
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
void CBTNotifSettingsTracker::ConstructL()
|
|
48 |
{
|
|
49 |
iSettings = CBTEngSettings::NewL( this );
|
|
50 |
User::LeaveIfError( iSettings->GetPowerState( iPowerState ) );
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
// NewL.
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
//
|
|
58 |
CBTNotifSettingsTracker* CBTNotifSettingsTracker::NewL( CBTNotifServer* aServer )
|
|
59 |
{
|
|
60 |
CBTNotifSettingsTracker* self = new( ELeave ) CBTNotifSettingsTracker( aServer );
|
|
61 |
CleanupStack::PushL( self );
|
|
62 |
self->ConstructL();
|
|
63 |
CleanupStack::Pop( self );
|
|
64 |
return self;
|
|
65 |
}
|
|
66 |
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// Destructor
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CBTNotifSettingsTracker::~CBTNotifSettingsTracker()
|
|
73 |
{
|
|
74 |
if( iNotification )
|
|
75 |
{
|
|
76 |
// Clear the notification callback, we cannot receive them anymore.
|
|
77 |
iNotification->RemoveObserver();
|
|
78 |
iNotification->Close(); // Also dequeues the notification from the queue.
|
|
79 |
iNotification = NULL;
|
|
80 |
}
|
|
81 |
delete iSettings;
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// Process a client message related to notifiers.
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CBTNotifSettingsTracker::DispatchNotifierMessageL( const RMessage2& aMessage )
|
|
90 |
{
|
|
91 |
TUid uid = TUid::Uid( aMessage.Int0() );
|
|
92 |
(void) uid;
|
|
93 |
}
|
|
94 |
|
|
95 |
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
// Cancels an outstanding client message related to notifiers.
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
//
|
|
100 |
void CBTNotifSettingsTracker::CancelNotifierMessageL( const RMessage2& aMessage )
|
|
101 |
{
|
|
102 |
(void) aMessage;
|
|
103 |
}
|
|
104 |
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
// From class MBTEngSettingsObserver.
|
|
108 |
// Handle a power status change.
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
//
|
|
111 |
void CBTNotifSettingsTracker::PowerStateChanged( TBTPowerStateValue aState )
|
|
112 |
{
|
|
113 |
iPowerState = aState;
|
|
114 |
TRAP_IGNORE( iServer->HandlePowerStateChangeL( aState ) );
|
|
115 |
}
|
|
116 |
|
|
117 |
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
// From class MBTEngSettingsObserver.
|
|
120 |
// Handle a visibility mode change.
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CBTNotifSettingsTracker::VisibilityModeChanged( TBTVisibilityMode aState )
|
|
124 |
{
|
|
125 |
if( iVisibilityMode == EBTVisibilityModeTemporary &&
|
|
126 |
aState == EBTVisibilityModeHidden && iPowerState == EBTPowerOn )
|
|
127 |
{
|
|
128 |
// Timeout expired, launch a note.
|
|
129 |
// Note that we get the power state change before this one, when powering
|
|
130 |
// off and setting visibility mode to hidden automatically.
|
|
131 |
NOTIF_NOTHANDLED( !iNotification )
|
|
132 |
iNotification = iServer->NotificationManager()->GetNotification();
|
|
133 |
if ( iNotification )
|
|
134 |
{
|
|
135 |
iNotification->SetObserver( this );
|
|
136 |
iNotification->SetNotificationType( TBluetoothDeviceDialog::ENote, EVisibilityTimeout );
|
|
137 |
iServer->NotificationManager()->QueueNotification( iNotification );
|
|
138 |
}
|
|
139 |
}
|
|
140 |
iVisibilityMode = aState;
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
// ---------------------------------------------------------------------------
|
|
145 |
// From class MBTNotificationResult.
|
|
146 |
// Handle a result from a user query.
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
void CBTNotifSettingsTracker::MBRDataReceived( CHbSymbianVariantMap& aData )
|
|
150 |
{
|
|
151 |
(void) aData;
|
|
152 |
}
|
|
153 |
|
|
154 |
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
// From class MBTNotificationResult.
|
|
157 |
// The notification is finished.
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
//
|
|
160 |
void CBTNotifSettingsTracker::MBRNotificationClosed( TInt aError, const TDesC8& aData )
|
|
161 |
{
|
|
162 |
(void) aError;
|
|
163 |
(void) aData;
|
|
164 |
iNotification->RemoveObserver();
|
|
165 |
iNotification = NULL;
|
|
166 |
}
|