|
1 /* |
|
2 * Copyright (c) 2007 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: This is the implementation of the CallAudioControlRepository class. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CallAudioControlRepository.h" |
|
20 #include "CallAudioControlImpl.h" |
|
21 #include "CallAudioControlCommon.h" |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // CCallAudioControlRepository::NewL |
|
25 // |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 CCallAudioControlRepository* CCallAudioControlRepository::NewL( |
|
29 CCallAudioControlImpl* aImplParent, const TUid aUid, |
|
30 const TUint32 aKey, TAction aAction) |
|
31 { |
|
32 CCallAudioControlRepository* self = |
|
33 new (ELeave) CCallAudioControlRepository(); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(aImplParent, aUid, aKey, aAction); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CCallAudioControlRepository::CCallAudioControlRepository |
|
42 // C++ constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CCallAudioControlRepository::CCallAudioControlRepository() : |
|
46 CActive(EPriorityNormal), iSubscribed(EFalse) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CCallAudioControlRepository::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CCallAudioControlRepository::ConstructL( |
|
56 CCallAudioControlImpl* aImplParent, const TUid aUid, |
|
57 const TUint32 aKey, TAction aAction) |
|
58 { |
|
59 CAC_TRACE1(_L("CCallAudioControlRepository::ConstructL enter")); |
|
60 iImplParent = aImplParent; |
|
61 iAction = aAction; |
|
62 iKey = aKey; |
|
63 //Create Repository object: |
|
64 iRepository = CRepository::NewL(aUid); |
|
65 CActiveScheduler::Add(this); |
|
66 CAC_TRACE1(_L("CCallAudioControlRepository::ConstructL exit")); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CCallAudioControlRepository::DestructL |
|
71 // Destructor |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CCallAudioControlRepository::~CCallAudioControlRepository() |
|
75 { |
|
76 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::~CCallAudioControlRepository enter"),this); |
|
77 Cancel(); |
|
78 delete iRepository; |
|
79 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::~CCallAudioControlRepository exit"),this); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CCallAudioControlRepository::NotifyRequest |
|
84 // ?implementation_description |
|
85 // (other items were commented in a header). |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 void CCallAudioControlRepository::NotifyRequest() |
|
89 { |
|
90 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::NotifyRequest"),this); |
|
91 if (!IsActive()) |
|
92 { |
|
93 iRepository->NotifyRequest(iKey, iStatus); |
|
94 SetActive(); |
|
95 } |
|
96 iSubscribed = ETrue; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CCallAudioControlRepository::NotifyCancel |
|
101 // ?implementation_description |
|
102 // (other items were commented in a header). |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 void CCallAudioControlRepository::NotifyCancel() |
|
106 { |
|
107 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::NotifyCancel"),this); |
|
108 iRepository->NotifyCancel(iKey); |
|
109 iSubscribed = EFalse; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CCallAudioControlRepository::Get |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CCallAudioControlRepository::Get(TInt& aValue) |
|
117 { |
|
118 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::Get"), this); |
|
119 TInt error = iRepository->Get(iKey, aValue); |
|
120 return error; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CCallAudioControlRepository::Set |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CCallAudioControlRepository::Set(TInt aValue) |
|
128 { |
|
129 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::Set"), this); |
|
130 TInt error = iRepository->Set(iKey, aValue); |
|
131 return error; |
|
132 } |
|
133 |
|
134 // |
|
135 // Methods required for CActive |
|
136 // |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CCallAudioControlRepository::DoCancel |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CCallAudioControlRepository::DoCancel() |
|
142 { |
|
143 if (iSubscribed) |
|
144 { |
|
145 iRepository->NotifyCancel(iKey); |
|
146 iSubscribed = EFalse; |
|
147 } |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CCallAudioControlRepository::RunL |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CCallAudioControlRepository::RunL() |
|
155 { |
|
156 CAC_TRACE2(_L("CCallAudioControlRepository[%x]::RunL"), this); |
|
157 TInt value; |
|
158 TInt err = iRepository->Get(iKey, value); |
|
159 if (err != KErrNone) |
|
160 { |
|
161 CAC_TRACE3(_L("CCallAudioControlRepository[%x]::RunL ERROR From Get: %d"), this,err); |
|
162 } |
|
163 // Notify CallAudioControl of change: |
|
164 if (iImplParent != NULL) |
|
165 { |
|
166 iImplParent->NotifyL(iAction, err, value); |
|
167 } |
|
168 // Set self up to get future vol change notifications |
|
169 iSubscribed = EFalse; |
|
170 NotifyRequest(); |
|
171 |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CCallAudioControlRepository::RunError |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CCallAudioControlRepository::RunError() |
|
179 { |
|
180 return KErrNone; |
|
181 } |
|
182 |
|
183 // End of file |