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 <tmsringtoneobsrvr.h> |
|
20 #include "tmsutility.h" |
|
21 #include "tmsproxy.h" |
|
22 #include "tmsringtonebodyimpl.h" |
|
23 |
|
24 using namespace TMS; |
|
25 |
|
26 TMSRingToneBodyImpl::TMSRingToneBodyImpl() : |
|
27 iObserver(NULL), |
|
28 iProxy(NULL), |
|
29 iParent(NULL) |
|
30 { |
|
31 } |
|
32 |
|
33 TMSRingToneBodyImpl::~TMSRingToneBodyImpl() |
|
34 { |
|
35 if (iProxy) |
|
36 { |
|
37 iProxy->Close(); |
|
38 } |
|
39 delete iProxy; |
|
40 iObserver = NULL; |
|
41 iParent = NULL; |
|
42 } |
|
43 |
|
44 gint TMSRingToneBodyImpl::Create(TMSRingToneBody*& bodyimpl) |
|
45 { |
|
46 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
47 TMSRingToneBodyImpl* self = new TMSRingToneBodyImpl(); |
|
48 if (self) |
|
49 { |
|
50 ret = self->PostConstruct(); |
|
51 if (ret != TMS_RESULT_SUCCESS) |
|
52 { |
|
53 delete self; |
|
54 self = NULL; |
|
55 } |
|
56 } |
|
57 bodyimpl = self; |
|
58 return ret; |
|
59 } |
|
60 |
|
61 gint TMSRingToneBodyImpl::Create(TMSRingToneBody*& bodyimpl, |
|
62 RWindow& /*window*/, gint /*scrid*/) |
|
63 { |
|
64 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
65 TMSRingToneBodyImpl* self = new TMSRingToneBodyImpl(); |
|
66 if (self) |
|
67 { |
|
68 ret = self->PostConstruct(); |
|
69 if (ret != TMS_RESULT_SUCCESS) |
|
70 { |
|
71 delete self; |
|
72 self = NULL; |
|
73 } |
|
74 } |
|
75 bodyimpl = self; |
|
76 return ret; |
|
77 } |
|
78 |
|
79 gint TMSRingToneBodyImpl::PostConstruct() |
|
80 { |
|
81 gint ret(TMS_RESULT_SUCCESS); |
|
82 iClientId = 1; |
|
83 iProxy = new TMSProxy(); |
|
84 if (!iProxy) |
|
85 { |
|
86 ret = TMS_RESULT_INSUFFICIENT_MEMORY; |
|
87 } |
|
88 else |
|
89 { |
|
90 if (iProxy->Connect() != TMS_RESULT_SUCCESS) |
|
91 { |
|
92 delete iProxy; |
|
93 iProxy = NULL; |
|
94 ret = TMS_RESULT_FATAL_ERROR; |
|
95 } |
|
96 } |
|
97 RET_REASON_IF_ERR(ret); |
|
98 return ret; |
|
99 } |
|
100 |
|
101 gint TMSRingToneBodyImpl::AddObserver(TMSRingToneObserver& obsrvr, |
|
102 gpointer user_data) |
|
103 { |
|
104 gint ret(TMS_RESULT_SUCCESS); |
|
105 if (!iObserver) |
|
106 { |
|
107 iObserver = &obsrvr; |
|
108 iUserData = user_data; |
|
109 if (iProxy) |
|
110 { |
|
111 ret = iProxy->SetMsgQueueNotifier(EMsgQueueRingtoneType, iObserver, |
|
112 iParent, iClientId); |
|
113 } |
|
114 else |
|
115 { |
|
116 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
117 } |
|
118 } |
|
119 else |
|
120 { |
|
121 ret = TMS_RESULT_ALREADY_EXIST; |
|
122 } |
|
123 return ret; |
|
124 } |
|
125 |
|
126 gint TMSRingToneBodyImpl::RemoveObserver(TMSRingToneObserver& obsrvr) |
|
127 { |
|
128 gint ret(TMS_RESULT_SUCCESS); |
|
129 if (iProxy && (&obsrvr == iObserver)) |
|
130 { |
|
131 ret = iProxy->RemoveMsgQueueNotifier(EMsgQueueRingtoneType, iObserver); |
|
132 iObserver = NULL; |
|
133 } |
|
134 else |
|
135 { |
|
136 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
137 } |
|
138 return ret; |
|
139 } |
|
140 |
|
141 gint TMSRingToneBodyImpl::Init(const TMSRingToneType type, GString* str, |
|
142 GString* tts) |
|
143 { |
|
144 gint ret(TMS_RESULT_SUCCESS); |
|
145 if (iProxy) |
|
146 { |
|
147 ret = iProxy->InitRT(type, str, tts); |
|
148 } |
|
149 else |
|
150 { |
|
151 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
152 } |
|
153 return ret; |
|
154 } |
|
155 |
|
156 gint TMSRingToneBodyImpl::Deinit() |
|
157 { |
|
158 gint ret(TMS_RESULT_SUCCESS); |
|
159 if (iProxy) |
|
160 { |
|
161 ret = iProxy->DeinitRT(); |
|
162 } |
|
163 else |
|
164 { |
|
165 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
166 } |
|
167 return ret; |
|
168 } |
|
169 |
|
170 gint TMSRingToneBodyImpl::Play() |
|
171 { |
|
172 gint ret(TMS_RESULT_SUCCESS); |
|
173 if (iProxy) |
|
174 { |
|
175 ret = iProxy->PlayRT(); |
|
176 } |
|
177 else |
|
178 { |
|
179 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
180 } |
|
181 return ret; |
|
182 } |
|
183 |
|
184 gint TMSRingToneBodyImpl::Stop() |
|
185 { |
|
186 gint ret(TMS_RESULT_SUCCESS); |
|
187 if (iProxy) |
|
188 { |
|
189 ret = iProxy->StopRT(); |
|
190 } |
|
191 else |
|
192 { |
|
193 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
194 } |
|
195 return ret; |
|
196 } |
|
197 |
|
198 gint TMSRingToneBodyImpl::Pause() |
|
199 { |
|
200 gint ret(TMS_RESULT_SUCCESS); |
|
201 if (iProxy) |
|
202 { |
|
203 ret = iProxy->PauseRT(); |
|
204 } |
|
205 else |
|
206 { |
|
207 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
208 } |
|
209 return ret; |
|
210 } |
|
211 |
|
212 gint TMSRingToneBodyImpl::Mute() |
|
213 { |
|
214 gint ret(TMS_RESULT_SUCCESS); |
|
215 if (iProxy) |
|
216 { |
|
217 ret = iProxy->MuteRT(); |
|
218 } |
|
219 else |
|
220 { |
|
221 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
222 } |
|
223 return ret; |
|
224 } |
|
225 |
|
226 void TMSRingToneBodyImpl::SetParent(TMSRingTone*& parent) |
|
227 { |
|
228 iParent = parent; |
|
229 } |
|
230 |
|