|
1 /* |
|
2 * Copyright (c) 2008 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: Checks if wlan scan state changes and informs observer of it |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Include Files |
|
20 #include <centralrepository.h> |
|
21 #include <ProfileEngineSDKCRKeys.h> |
|
22 #include "cmscheduler.h" |
|
23 #include "cmcenrepnotifier.h" |
|
24 #include "msdebug.h" |
|
25 |
|
26 // Two-phased constructor. |
|
27 CCmCenrepNotifier* CCmCenrepNotifier::NewL( CCmScheduler& aScheduler ) |
|
28 { |
|
29 CCmCenrepNotifier* self = new (ELeave) CCmCenrepNotifier( aScheduler ); |
|
30 |
|
31 CleanupStack::PushL( self ); |
|
32 CActiveScheduler::Add( self ); |
|
33 self->ConstructL(); |
|
34 CleanupStack::Pop(); |
|
35 return self; |
|
36 } |
|
37 |
|
38 void CCmCenrepNotifier::ConstructL() |
|
39 { |
|
40 // open central repository |
|
41 iRepository = CRepository::NewL( KCRUidProfileEngine ); |
|
42 // assign notification request |
|
43 RequestNotification(); |
|
44 } |
|
45 |
|
46 // -------------------------------------------------------------------------- |
|
47 // CCmCenrepNotifier::CCmCenrepNotifier |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // -------------------------------------------------------------------------- |
|
51 // |
|
52 CCmCenrepNotifier::CCmCenrepNotifier( CCmScheduler& aScheduler ) : |
|
53 CActive( CActive::EPriorityStandard ), iScheduler( aScheduler ) |
|
54 { |
|
55 LOG(_L("[Cm Scheduler]\t CCmCenrepNotifier::CCmCenrepNotifier()")); |
|
56 } |
|
57 |
|
58 // Destructor |
|
59 CCmCenrepNotifier::~CCmCenrepNotifier() |
|
60 { |
|
61 LOG(_L("[Cm Scheduler]\t CCmCenrepNotifier::~CCmCenrepNotifier()")); |
|
62 |
|
63 Cancel(); |
|
64 delete iRepository; |
|
65 } |
|
66 |
|
67 // -------------------------------------------------------------------------- |
|
68 // CCmCenrepNotifier::RequestNotification |
|
69 // Requests database notification |
|
70 // -------------------------------------------------------------------------- |
|
71 // |
|
72 void CCmCenrepNotifier::RequestNotification() |
|
73 { |
|
74 LOG(_L("[Cm Scheduler]\t CCmCenrepNotifier::RequestNotification()")); |
|
75 if ( !IsActive() ) |
|
76 { |
|
77 iRepository->NotifyRequest( KProEngActiveProfile, iStatus ); |
|
78 SetActive(); |
|
79 } |
|
80 } |
|
81 |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // CCmCenrepNotifier::DoCancel |
|
85 // -------------------------------------------------------------------------- |
|
86 // |
|
87 void CCmCenrepNotifier::DoCancel() |
|
88 { |
|
89 // cancel possible requests |
|
90 iRepository->NotifyCancelAll(); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CCmCenrepNotifier::RunL |
|
95 // Called when change in database occurs |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CCmCenrepNotifier::RunL() |
|
99 { |
|
100 LOG(_L("[Cm Scheduler]\t CCmCenrepNotifier::RunL()")); |
|
101 |
|
102 // Get ID of current profile |
|
103 TInt profile( 0 ); |
|
104 User::LeaveIfError( GetCurrentProfile( profile ) ); |
|
105 |
|
106 iScheduler.ProfileChangedL( profile ); |
|
107 |
|
108 // Assign new request |
|
109 RequestNotification(); |
|
110 } |
|
111 |
|
112 // -------------------------------------------------------------------------- |
|
113 // CCmCenrepNotifier::RunError |
|
114 // Called if RunL leaves |
|
115 // -------------------------------------------------------------------------- |
|
116 // |
|
117 #ifdef _DEBUG |
|
118 TInt CCmCenrepNotifier::RunError( TInt aError ) |
|
119 #else // _DEBUG |
|
120 TInt CCmCenrepNotifier::RunError( TInt /*aError*/ ) |
|
121 #endif // _DEBUG |
|
122 { |
|
123 TRACE(Print(_L("[Cm Scheduler]\t \ |
|
124 CCmCenrepNotifier::RunError errorcode = %d"), aError)); |
|
125 |
|
126 return KErrNone; |
|
127 } |
|
128 |
|
129 // -------------------------------------------------------------------------- |
|
130 // CCmCenrepNotifier::GetCurrentProfile |
|
131 // -------------------------------------------------------------------------- |
|
132 // |
|
133 TInt CCmCenrepNotifier::GetCurrentProfile( TInt& aProfile ) |
|
134 { |
|
135 LOG(_L("[Cm Scheduler]\t CCmCenrepNotifier::GetCurrentProfile()")); |
|
136 |
|
137 return iRepository->Get( KProEngActiveProfile, aProfile ); |
|
138 } |
|
139 |
|
140 // End of file |