|
1 /* |
|
2 * Copyright (c) 2009 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: Telephony Multimedia Service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <tms.h> |
|
19 #include <tmseffectobsrvr.h> |
|
20 #include "tmscallproxy.h" |
|
21 #include "tmsqueuehandler.h" |
|
22 #include "tmsgaineffectbodyimpl.h" |
|
23 |
|
24 using namespace TMS; |
|
25 |
|
26 TMSGainEffectBodyImpl::TMSGainEffectBodyImpl() : |
|
27 iObserver(NULL), |
|
28 iProxy(NULL), |
|
29 iParentEffect(NULL) |
|
30 { |
|
31 } |
|
32 |
|
33 TMSGainEffectBodyImpl::~TMSGainEffectBodyImpl() |
|
34 { |
|
35 } |
|
36 |
|
37 gint TMSGainEffectBodyImpl::Create(TMSGainEffectBody*& bodyimpl) |
|
38 { |
|
39 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
40 TMSGainEffectBodyImpl* self = new TMSGainEffectBodyImpl; |
|
41 if (self) |
|
42 { |
|
43 ret = self->PostConstruct(); |
|
44 if (ret != TMS_RESULT_SUCCESS) |
|
45 { |
|
46 delete self; |
|
47 self = NULL; |
|
48 } |
|
49 } |
|
50 bodyimpl = self; |
|
51 return ret; |
|
52 } |
|
53 |
|
54 gint TMSGainEffectBodyImpl::PostConstruct() |
|
55 { |
|
56 gint ret(TMS_RESULT_SUCCESS); |
|
57 return ret; |
|
58 } |
|
59 |
|
60 gint TMSGainEffectBodyImpl::AddObserver(TMSEffectObserver& obsrvr, |
|
61 gpointer user_data) |
|
62 { |
|
63 gint ret(TMS_RESULT_SUCCESS); |
|
64 if (!iObserver) |
|
65 { |
|
66 iObserver = &obsrvr; |
|
67 iUserData = user_data; |
|
68 } |
|
69 else |
|
70 { |
|
71 ret = TMS_RESULT_ALREADY_EXIST; |
|
72 } |
|
73 return ret; |
|
74 } |
|
75 |
|
76 /** |
|
77 * Remove a stream observer from this stream. |
|
78 * |
|
79 * This function can be called at any time. It is recommended to remove |
|
80 * observer after calling Deinit() on stream. Else observer may receive |
|
81 * a callback that is alread dispatched. |
|
82 * |
|
83 * @param obsrvr |
|
84 * The listener to remove. |
|
85 * |
|
86 * @return |
|
87 * TMS_RESULT_SUCCESS if the obsrvr is removed successfully from list. |
|
88 * TMS_RESULT_DOES_NOT_EXIST if obsrvr is not already in the list. |
|
89 * |
|
90 */ |
|
91 gint TMSGainEffectBodyImpl::RemoveObserver(TMSEffectObserver& obsrvr) |
|
92 { |
|
93 gint ret(TMS_RESULT_SUCCESS); |
|
94 if (&obsrvr == iObserver) |
|
95 { |
|
96 iObserver = NULL; |
|
97 } |
|
98 else |
|
99 { |
|
100 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
101 } |
|
102 return ret; |
|
103 } |
|
104 |
|
105 gint TMSGainEffectBodyImpl::GetLevel(guint& level) |
|
106 { |
|
107 gint ret(TMS_RESULT_SUCCESS); |
|
108 if (iProxy) |
|
109 { |
|
110 ret = iProxy->GetGain(level); |
|
111 } |
|
112 else |
|
113 { |
|
114 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
115 } |
|
116 return ret; |
|
117 } |
|
118 |
|
119 gint TMSGainEffectBodyImpl::SetLevel(const guint level) |
|
120 { |
|
121 gint ret(TMS_RESULT_SUCCESS); |
|
122 if (iProxy) |
|
123 { |
|
124 ret = iProxy->SetGain(level); |
|
125 } |
|
126 else |
|
127 { |
|
128 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
129 } |
|
130 return ret; |
|
131 } |
|
132 |
|
133 gint TMSGainEffectBodyImpl::GetMaxLevel(guint& level) |
|
134 { |
|
135 gint ret(TMS_RESULT_SUCCESS); |
|
136 if (iProxy) |
|
137 { |
|
138 ret = iProxy->GetMaxGain(level); |
|
139 } |
|
140 else |
|
141 { |
|
142 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
143 } |
|
144 return ret; |
|
145 } |
|
146 |
|
147 gint TMSGainEffectBodyImpl::GetType(TMSEffectType& effecttype) |
|
148 { |
|
149 gint ret(TMS_RESULT_SUCCESS); |
|
150 effecttype = TMS_EFFECT_GAIN; |
|
151 return ret; |
|
152 } |
|
153 |
|
154 gint TMSGainEffectBodyImpl::SetParentEffect(TMSEffect*& parenteffect) |
|
155 { |
|
156 gint ret(TMS_RESULT_SUCCESS); |
|
157 iParentEffect = NULL; |
|
158 iParentEffect = parenteffect; |
|
159 return ret; |
|
160 } |
|
161 |
|
162 void TMSGainEffectBodyImpl::SetProxy(TMSCallProxy* aProxy, |
|
163 gpointer queuehandler) |
|
164 { |
|
165 iProxy = aProxy; |
|
166 ((CQueueHandler*) queuehandler)->AddObserver(*this, TMS_EFFECT_GAIN); |
|
167 } |
|
168 |
|
169 void TMSGainEffectBodyImpl::QueueEvent(TInt aEventType, TInt aError, |
|
170 void* /*user_data*/) |
|
171 { |
|
172 TMSSignalEvent event; |
|
173 |
|
174 event.type = TMS_EVENT_EFFECT_GAIN_CHANGED; |
|
175 event.reason = aError; |
|
176 |
|
177 switch (aEventType) |
|
178 { |
|
179 case TMS_EVENT_EFFECT_GAIN_CHANGED: |
|
180 { |
|
181 if (iObserver && iParentEffect) |
|
182 { |
|
183 iObserver->EffectsEvent(iParentEffect, event); |
|
184 } |
|
185 } |
|
186 break; |
|
187 default: |
|
188 break; |
|
189 } |
|
190 } |
|
191 |
|
192 // End of file |