|
1 /* |
|
2 * Copyright (c) 2005 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: Contains phone engine central repository monitor base class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cpecenrepmonitor.h" |
|
21 #include <centralrepository.h> |
|
22 #include <pepanic.pan> |
|
23 #include <talogger.h> |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CPECenRepMonitor::CPECenRepMonitor |
|
27 // C++ default constructor can NOT contain any code, that |
|
28 // might leave. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CPECenRepMonitor::CPECenRepMonitor( |
|
32 TUint32 aMonitorSetting |
|
33 ) : CActive( EPriorityStandard ), |
|
34 iMonitorSetting( aMonitorSetting ) |
|
35 { |
|
36 CActiveScheduler::Add( this ); |
|
37 } |
|
38 |
|
39 // Destructor |
|
40 CPECenRepMonitor::~CPECenRepMonitor( |
|
41 // None |
|
42 ) |
|
43 { |
|
44 Cancel(); |
|
45 delete iRepository; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CPECenRepMonitor::BaseConstructL |
|
50 // Symbian 2nd phase constructor can leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CPECenRepMonitor::BaseConstructL( |
|
54 TUid aRepositoryUid |
|
55 ) |
|
56 { |
|
57 // Create repository instance |
|
58 iRepository = CRepository::NewL( aRepositoryUid ); |
|
59 |
|
60 // Store current value |
|
61 UpdateL(); |
|
62 |
|
63 // Start monitoring |
|
64 SubmitNotifyRequestL(); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPECenRepMonitor::Get |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 TInt CPECenRepMonitor::Get( |
|
72 TInt& aValue |
|
73 ) |
|
74 { |
|
75 return ( iRepository->Get( iMonitorSetting, aValue ) ); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CPECenRepMonitor::SubmitNotifyRequestL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CPECenRepMonitor::SubmitNotifyRequestL( |
|
83 // None |
|
84 ) |
|
85 { |
|
86 __ASSERT_DEBUG( iRepository, Panic( EPEPanicNoRepository ) ); |
|
87 __ASSERT_DEBUG( !IsActive(), Panic( EPEPanicRepositoryAlreadyActive ) ); |
|
88 iRepository->NotifyRequest( iMonitorSetting, iStatus ); |
|
89 SetActive(); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CPECenRepMonitor::DoCancel |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CPECenRepMonitor::DoCancel( |
|
97 // None |
|
98 ) |
|
99 { |
|
100 __ASSERT_DEBUG( iRepository, Panic( EPEPanicNoRepository ) ); |
|
101 iRepository->NotifyCancel( iMonitorSetting ); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CPECenRepMonitor::RunError |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 TInt CPECenRepMonitor::RunError( |
|
109 #ifdef _DEBUG |
|
110 TInt aError // Log the leavecode from RunL |
|
111 #else |
|
112 TInt /*aError*/ |
|
113 #endif |
|
114 ) |
|
115 { |
|
116 #ifdef _DEBUG |
|
117 TEFLOGSTRING3( KTAERROR, "CPECenRepMonitor::RunError %d MonitorSetting: %d", aError, iMonitorSetting ); |
|
118 #endif |
|
119 return ( KErrNone ); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CPECenRepMonitor::RunL |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 void CPECenRepMonitor::RunL( |
|
127 // None |
|
128 ) |
|
129 { |
|
130 TEFLOGSTRING3( KTAREQEND, "CPECenRepMonitor::RunL, status: %d, monitored setting: %d", iStatus.Int(), iMonitorSetting ); |
|
131 |
|
132 // Don't resubmit the request on error |
|
133 // Central repositry completes notifications with id of setting |
|
134 // so check only that value of iStatus is negative |
|
135 User::LeaveIfError( iStatus.Int() < KErrNone ); |
|
136 SubmitNotifyRequestL(); |
|
137 UpdateL(); |
|
138 } |
|
139 |
|
140 // End of file |