|
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 "tmsproxy.h" |
|
21 #include "tmsutility.h" |
|
22 #include "tmsglobalgaineffectbodyimpl.h" |
|
23 |
|
24 using namespace TMS; |
|
25 |
|
26 TMSGlobalGainEffectBodyImpl::TMSGlobalGainEffectBodyImpl() : |
|
27 iObserver(NULL), |
|
28 iProxy(NULL), |
|
29 iGlobalEffect(NULL) |
|
30 { |
|
31 } |
|
32 |
|
33 TMSGlobalGainEffectBodyImpl::~TMSGlobalGainEffectBodyImpl() |
|
34 { |
|
35 if (iProxy) |
|
36 { |
|
37 iProxy->Close(); |
|
38 delete iProxy; |
|
39 iProxy = NULL; |
|
40 } |
|
41 iObserver = NULL; |
|
42 iGlobalEffect = NULL; |
|
43 iUserData = NULL; |
|
44 } |
|
45 |
|
46 gint TMSGlobalGainEffectBodyImpl::Create(TMSGlobalGainEffectBody*& bodyimpl) |
|
47 { |
|
48 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
49 TMSGlobalGainEffectBodyImpl* self = new TMSGlobalGainEffectBodyImpl; |
|
50 if (self) |
|
51 { |
|
52 ret = self->PostConstruct(); |
|
53 if (ret != TMS_RESULT_SUCCESS) |
|
54 { |
|
55 delete self; |
|
56 self = NULL; |
|
57 } |
|
58 } |
|
59 bodyimpl = self; |
|
60 return ret; |
|
61 } |
|
62 |
|
63 gint TMSGlobalGainEffectBodyImpl::PostConstruct() |
|
64 { |
|
65 gint ret(TMS_RESULT_SUCCESS); |
|
66 iClientId = 1; |
|
67 iProxy = new TMSProxy; |
|
68 |
|
69 if (iProxy) |
|
70 { |
|
71 if (iProxy->Connect() != TMS_RESULT_SUCCESS) |
|
72 { |
|
73 delete iProxy; |
|
74 iProxy = NULL; |
|
75 ret = TMS_RESULT_FATAL_ERROR; |
|
76 } |
|
77 } |
|
78 else |
|
79 { |
|
80 ret = TMS_RESULT_INSUFFICIENT_MEMORY; |
|
81 } |
|
82 return ret; |
|
83 } |
|
84 |
|
85 gint TMSGlobalGainEffectBodyImpl::AddObserver(TMSEffectObserver& obsrvr, |
|
86 gpointer /*user_data*/) |
|
87 { |
|
88 gint ret(TMS_RESULT_SUCCESS); |
|
89 if (!iObserver) |
|
90 { |
|
91 iObserver = &obsrvr; |
|
92 //iUserData = user_data; |
|
93 if (iProxy) |
|
94 { |
|
95 ret = iProxy->SetMsgQueueNotifier(EMsgQueueGlobalGainType, |
|
96 iObserver, iGlobalEffect, iClientId); |
|
97 } |
|
98 else |
|
99 { |
|
100 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
101 } |
|
102 } |
|
103 else |
|
104 { |
|
105 ret = TMS_RESULT_ALREADY_EXIST; |
|
106 } |
|
107 |
|
108 return ret; |
|
109 } |
|
110 |
|
111 gint TMSGlobalGainEffectBodyImpl::RemoveObserver(TMSEffectObserver& obsrvr) |
|
112 { |
|
113 gint ret(TMS_RESULT_SUCCESS); |
|
114 |
|
115 if (iProxy && (&obsrvr == iObserver)) |
|
116 { |
|
117 ret = iProxy->RemoveMsgQueueNotifier(EMsgQueueGlobalGainType, |
|
118 iObserver); |
|
119 iObserver = NULL; |
|
120 } |
|
121 else |
|
122 { |
|
123 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
124 } |
|
125 return ret; |
|
126 } |
|
127 |
|
128 gint TMSGlobalGainEffectBodyImpl::GetLevel(guint& level) |
|
129 { |
|
130 gint ret(TMS_RESULT_SUCCESS); |
|
131 if (iProxy) |
|
132 { |
|
133 ret = iProxy->GetGain(level); |
|
134 } |
|
135 else |
|
136 { |
|
137 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
138 } |
|
139 return ret; |
|
140 } |
|
141 |
|
142 gint TMSGlobalGainEffectBodyImpl::SetLevel(const guint level) |
|
143 { |
|
144 gint ret(TMS_RESULT_SUCCESS); |
|
145 if (iProxy) |
|
146 { |
|
147 ret = iProxy->SetGain(level); |
|
148 } |
|
149 else |
|
150 { |
|
151 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
152 } |
|
153 return ret; |
|
154 } |
|
155 |
|
156 gint TMSGlobalGainEffectBodyImpl::GetMaxLevel(guint& level) |
|
157 { |
|
158 gint ret(TMS_RESULT_SUCCESS); |
|
159 if (iProxy) |
|
160 { |
|
161 ret = iProxy->GetMaxGain(level); |
|
162 } |
|
163 else |
|
164 { |
|
165 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
166 } |
|
167 return ret; |
|
168 } |
|
169 |
|
170 gint TMSGlobalGainEffectBodyImpl::GetType(TMSEffectType& effecttype) |
|
171 { |
|
172 gint ret(TMS_RESULT_SUCCESS); |
|
173 effecttype = TMS_EFFECT_GLOBAL_GAIN; |
|
174 return ret; |
|
175 } |
|
176 |
|
177 void TMSGlobalGainEffectBodyImpl::SetParentEffect(TMSEffect*& parenteffect) |
|
178 { |
|
179 iGlobalEffect = NULL; |
|
180 iGlobalEffect = parenteffect; |
|
181 } |
|
182 |
|
183 // End of file |