21 #include "tmsutility.h" |
21 #include "tmsutility.h" |
22 |
22 |
23 using namespace TMS; |
23 using namespace TMS; |
24 |
24 |
25 // ----------------------------------------------------------------------------- |
25 // ----------------------------------------------------------------------------- |
26 // CSPCenRepListener::CSPCenRepListener |
26 // TMSCenRepListener::TMSCenRepListener |
27 // C++ default constructor can NOT contain any code, that |
27 // C++ default constructor can NOT contain any code, that |
28 // might leave. |
28 // might leave. |
29 // ----------------------------------------------------------------------------- |
29 // ----------------------------------------------------------------------------- |
30 // |
30 // |
31 CSPCenRepListener* CSPCenRepListener::NewL(TUid aUid, |
31 TMSCenRepListener* TMSCenRepListener::NewL(TUid aUid, |
32 TUint32 aMonitorSetting, MCSPCenRepObserver* aObserver) |
32 TUint32 aMonitorSetting, MCSPCenRepObserver* aObserver) |
33 { |
33 { |
34 TRACE_PRN_FN_ENT; |
34 TRACE_PRN_FN_ENT; |
35 CSPCenRepListener* self = new (ELeave) CSPCenRepListener(aUid, |
35 TMSCenRepListener* self = new (ELeave) TMSCenRepListener(aUid, |
36 aMonitorSetting, aObserver); |
36 aMonitorSetting, aObserver); |
37 CleanupStack::PushL(self); |
37 CleanupStack::PushL(self); |
38 self->ConstructL(); |
38 self->ConstructL(); |
39 CleanupStack::Pop(); |
39 CleanupStack::Pop(); |
40 TRACE_PRN_FN_EXT; |
40 TRACE_PRN_FN_EXT; |
41 return self; |
41 return self; |
42 } |
42 } |
43 |
43 |
44 // Destructor |
44 // Destructor |
45 CSPCenRepListener::~CSPCenRepListener() |
45 TMSCenRepListener::~TMSCenRepListener() |
46 { |
46 { |
47 TRACE_PRN_FN_ENT; |
47 TRACE_PRN_FN_ENT; |
48 Cancel(); |
48 Cancel(); |
49 delete iRepository; |
49 delete iRepository; |
50 TRACE_PRN_FN_EXT; |
50 TRACE_PRN_FN_EXT; |
51 } |
51 } |
52 |
52 |
53 // ----------------------------------------------------------------------------- |
53 // ----------------------------------------------------------------------------- |
54 // CSPCenRepListener::Get |
54 // TMSCenRepListener::Get |
55 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
56 // |
56 // |
57 TInt CSPCenRepListener::Get(TInt& aValue) |
57 gint TMSCenRepListener::Get(gint& aValue) |
58 { |
58 { |
59 TRACE_PRN_FN_ENT; |
59 TRACE_PRN_FN_ENT; |
|
60 gint status = iRepository->Get(iMonitorSetting, aValue); |
60 TRACE_PRN_FN_EXT; |
61 TRACE_PRN_FN_EXT; |
61 return (iRepository->Get(iMonitorSetting, aValue)); |
62 return status; |
62 |
|
63 } |
63 } |
64 |
64 |
65 // ----------------------------------------------------------------------------- |
65 // ----------------------------------------------------------------------------- |
66 // CSPCenRepListener::Set |
66 // TMSCenRepListener::Set |
67 // ----------------------------------------------------------------------------- |
67 // ----------------------------------------------------------------------------- |
68 // |
68 // |
69 TInt CSPCenRepListener::Set(TInt aValue) |
69 gint TMSCenRepListener::Set(gint aValue) |
70 { |
70 { |
71 TRACE_PRN_FN_ENT; |
71 TRACE_PRN_FN_ENT; |
|
72 gint status = iRepository->Set(iMonitorSetting, aValue); |
72 TRACE_PRN_FN_EXT; |
73 TRACE_PRN_FN_EXT; |
73 return (iRepository->Set(iMonitorSetting, aValue)); |
74 return status; |
74 |
75 |
75 } |
76 } |
76 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
77 // CSPCenRepListener::DoCancel |
78 // TMSCenRepListener::DoCancel |
78 // ----------------------------------------------------------------------------- |
79 // ----------------------------------------------------------------------------- |
79 // |
80 // |
80 void CSPCenRepListener::DoCancel() |
81 void TMSCenRepListener::DoCancel() |
81 { |
82 { |
82 TRACE_PRN_FN_ENT; |
83 TRACE_PRN_FN_ENT; |
83 iRepository->NotifyCancel(iMonitorSetting); |
84 iRepository->NotifyCancel(iMonitorSetting); |
84 TRACE_PRN_FN_EXT; |
85 TRACE_PRN_FN_EXT; |
85 } |
86 } |
86 |
87 |
87 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
88 // CSPCenRepListener::RunError |
89 // TMSCenRepListener::RunError |
89 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
90 // |
91 // |
91 TInt CSPCenRepListener::RunError( |
92 gint TMSCenRepListener::RunError( |
92 #ifdef _DEBUG |
93 #ifdef _DEBUG |
93 TInt aError // Log the leavecode from RunL |
94 TInt aError // Log the leavecode from RunL |
94 #else |
95 #else |
95 TInt /*aError*/ |
96 TInt /*aError*/ |
96 #endif |
97 #endif |
99 TRACE_PRN_FN_ENT; |
100 TRACE_PRN_FN_ENT; |
100 #ifdef _DEBUG |
101 #ifdef _DEBUG |
101 TRACE_PRN_IF_ERR(aError); |
102 TRACE_PRN_IF_ERR(aError); |
102 #endif |
103 #endif |
103 TRACE_PRN_FN_EXT; |
104 TRACE_PRN_FN_EXT; |
104 return ( KErrNone ); |
105 return KErrNone; |
105 } |
106 } |
106 |
107 |
107 // ----------------------------------------------------------------------------- |
108 // ----------------------------------------------------------------------------- |
108 // CSPCenRepListener::RunL |
109 // TMSCenRepListener::RunL |
109 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
110 // |
111 // |
111 void CSPCenRepListener::RunL() |
112 void TMSCenRepListener::RunL() |
112 { |
113 { |
113 TRACE_PRN_FN_ENT; |
114 TRACE_PRN_FN_ENT; |
114 // Don't resubmit the request on error |
115 // Don't resubmit the request on error |
115 // Central repositry completes notifications with id of setting |
116 // Central repositry completes notifications with id of setting |
116 // so check only that value of iStatus is negative |
117 // so check only that value of iStatus is negative |
117 User::LeaveIfError(iStatus.Int() < KErrNone); |
118 if (iStatus.Int() == KErrNone) |
118 SubmitNotifyRequestL(); |
119 { |
|
120 SubmitNotifyRequestL(); |
|
121 } |
119 |
122 |
120 TInt volume; |
|
121 // The loudspeaker volume has changed in repository. |
123 // The loudspeaker volume has changed in repository. |
122 // Retrieve the current volume from repository. |
124 // Retrieve the current volume from repository. |
123 User::LeaveIfError(Get(volume)); |
125 gint volume; |
124 |
126 Get(volume); |
125 iObserver->HandleNotifyCenRepL(iUid, iMonitorSetting, volume); |
127 iObserver->HandleNotifyCenRepL(iUid, iMonitorSetting, volume); |
126 TRACE_PRN_FN_EXT; |
128 TRACE_PRN_FN_EXT; |
127 } |
129 } |
128 |
130 |
129 // ----------------------------------------------------------------------------- |
131 // ----------------------------------------------------------------------------- |
130 // CSPCenRepListener::CSPCenRepListener |
132 // TMSCenRepListener::TMSCenRepListener |
131 // ----------------------------------------------------------------------------- |
133 // ----------------------------------------------------------------------------- |
132 // |
134 // |
133 CSPCenRepListener::CSPCenRepListener(TUid aUid, TUint32 aMonitorSetting, |
135 TMSCenRepListener::TMSCenRepListener(TUid aUid, TUint32 aMonitorSetting, |
134 MCSPCenRepObserver* aObserver) : |
136 MCSPCenRepObserver* aObserver) : |
135 CActive(EPriorityStandard), |
137 CActive(EPriorityStandard), |
136 iUid(aUid), |
138 iUid(aUid), |
137 iMonitorSetting(aMonitorSetting), |
139 iMonitorSetting(aMonitorSetting), |
138 iObserver(aObserver) |
140 iObserver(aObserver) |
141 CActiveScheduler::Add(this); |
143 CActiveScheduler::Add(this); |
142 TRACE_PRN_FN_EXT; |
144 TRACE_PRN_FN_EXT; |
143 } |
145 } |
144 |
146 |
145 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
146 // CSPCenRepListener::ConstructL |
148 // TMSCenRepListener::ConstructL |
147 // ----------------------------------------------------------------------------- |
149 // ----------------------------------------------------------------------------- |
148 // |
150 // |
149 void CSPCenRepListener::ConstructL() |
151 void TMSCenRepListener::ConstructL() |
150 { |
152 { |
151 TRACE_PRN_FN_ENT; |
153 TRACE_PRN_FN_ENT; |
152 // Create repository instance |
154 // Create repository instance |
153 iRepository = CRepository::NewL(iUid); |
155 iRepository = CRepository::NewL(iUid); |
154 // Start monitoring |
156 // Start monitoring |
155 SubmitNotifyRequestL(); |
157 SubmitNotifyRequestL(); |
156 TRACE_PRN_FN_EXT; |
158 TRACE_PRN_FN_EXT; |
157 } |
159 } |
158 |
160 |
159 // ----------------------------------------------------------------------------- |
161 // ----------------------------------------------------------------------------- |
160 // CSPCenRepListener::SubmitNotifyRequestL |
162 // TMSCenRepListener::SubmitNotifyRequestL |
161 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
162 // |
164 // |
163 void CSPCenRepListener::SubmitNotifyRequestL() |
165 void TMSCenRepListener::SubmitNotifyRequestL() |
164 { |
166 { |
165 TRACE_PRN_FN_ENT; |
167 TRACE_PRN_FN_ENT; |
|
168 iStatus = KRequestPending; |
166 iRepository->NotifyRequest(iMonitorSetting, iStatus); |
169 iRepository->NotifyRequest(iMonitorSetting, iStatus); |
167 SetActive(); |
170 SetActive(); |
168 TRACE_PRN_FN_EXT; |
171 TRACE_PRN_FN_EXT; |
169 } |
172 } |
170 |
173 |