|
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 // Start monitoring |
|
60 SubmitNotifyRequestL(); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CPECenRepMonitor::Get |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 TInt CPECenRepMonitor::Get( |
|
68 TInt& aValue |
|
69 ) |
|
70 { |
|
71 return ( iRepository->Get( iMonitorSetting, aValue ) ); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CPECenRepMonitor::SubmitNotifyRequestL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CPECenRepMonitor::SubmitNotifyRequestL( |
|
79 // None |
|
80 ) |
|
81 { |
|
82 __ASSERT_DEBUG( iRepository, Panic( EPEPanicNoRepository ) ); |
|
83 __ASSERT_DEBUG( !IsActive(), Panic( EPEPanicRepositoryAlreadyActive ) ); |
|
84 iRepository->NotifyRequest( iMonitorSetting, iStatus ); |
|
85 SetActive(); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CPECenRepMonitor::DoCancel |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CPECenRepMonitor::DoCancel( |
|
93 // None |
|
94 ) |
|
95 { |
|
96 __ASSERT_DEBUG( iRepository, Panic( EPEPanicNoRepository ) ); |
|
97 iRepository->NotifyCancel( iMonitorSetting ); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CPECenRepMonitor::RunError |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TInt CPECenRepMonitor::RunError( |
|
105 #ifdef _DEBUG |
|
106 TInt aError // Log the leavecode from RunL |
|
107 #else |
|
108 TInt /*aError*/ |
|
109 #endif |
|
110 ) |
|
111 { |
|
112 #ifdef _DEBUG |
|
113 TEFLOGSTRING3( KTAERROR, "CPECenRepMonitor::RunError %d MonitorSetting: %d", aError, iMonitorSetting ); |
|
114 #endif |
|
115 return ( KErrNone ); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CPECenRepMonitor::RunL |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CPECenRepMonitor::RunL( |
|
123 // None |
|
124 ) |
|
125 { |
|
126 TEFLOGSTRING3( KTAREQEND, "CPECenRepMonitor::RunL, status: %d, monitored setting: %d", iStatus.Int(), iMonitorSetting ); |
|
127 |
|
128 // Don't resubmit the request on error |
|
129 // Central repositry completes notifications with id of setting |
|
130 // so check only that value of iStatus is negative |
|
131 User::LeaveIfError( iStatus.Int() < KErrNone ); |
|
132 SubmitNotifyRequestL(); |
|
133 UpdateL(); |
|
134 } |
|
135 |
|
136 // End of file |