|
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 <tmsinbandtoneobsrvr.h> |
|
20 #include "tmsutility.h" |
|
21 #include "tmsproxy.h" |
|
22 #include "tmsinbandtonebodyimpl.h" |
|
23 |
|
24 using namespace TMS; |
|
25 |
|
26 TMSInbandToneBodyImpl::TMSInbandToneBodyImpl() : |
|
27 iObserver(NULL), |
|
28 iProxy(NULL), |
|
29 iParent(NULL) |
|
30 { |
|
31 } |
|
32 |
|
33 TMSInbandToneBodyImpl::~TMSInbandToneBodyImpl() |
|
34 { |
|
35 if (iProxy) |
|
36 { |
|
37 iProxy->Close(); |
|
38 delete iProxy; |
|
39 iProxy = NULL; |
|
40 } |
|
41 iObserver = NULL; |
|
42 iParent = NULL; |
|
43 iUserData = NULL; |
|
44 } |
|
45 |
|
46 gint TMSInbandToneBodyImpl::Create(TMSInbandToneBody*& bodyimpl) |
|
47 { |
|
48 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
49 TMSInbandToneBodyImpl* self = new TMSInbandToneBodyImpl(); |
|
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 TMSInbandToneBodyImpl::PostConstruct() |
|
64 { |
|
65 gint ret(TMS_RESULT_SUCCESS); |
|
66 iClientId = 1; |
|
67 iProxy = new TMSProxy; |
|
68 |
|
69 if (!iProxy) |
|
70 { |
|
71 ret = TMS_RESULT_INSUFFICIENT_MEMORY; |
|
72 } |
|
73 RET_REASON_IF_ERR(ret); |
|
74 |
|
75 if (iProxy->Connect() != TMS_RESULT_SUCCESS) |
|
76 { |
|
77 delete iProxy; |
|
78 iProxy = NULL; |
|
79 ret = TMS_RESULT_FATAL_ERROR; |
|
80 } |
|
81 RET_REASON_IF_ERR(ret); |
|
82 return ret; |
|
83 } |
|
84 |
|
85 gint TMSInbandToneBodyImpl::AddObserver(TMSInbandToneObserver& 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(EMsgQueueInbandToneType, |
|
96 iObserver, iParent, iClientId); |
|
97 if (ret == TMS_RESULT_SUCCESS) |
|
98 { |
|
99 //ret = iProxy->StartInbandToneNotifier(); |
|
100 } |
|
101 } |
|
102 else |
|
103 { |
|
104 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
105 } |
|
106 } |
|
107 else |
|
108 { |
|
109 ret = TMS_RESULT_ALREADY_EXIST; |
|
110 } |
|
111 return ret; |
|
112 } |
|
113 |
|
114 gint TMSInbandToneBodyImpl::RemoveObserver(TMSInbandToneObserver& obsrvr) |
|
115 { |
|
116 gint ret(TMS_RESULT_SUCCESS); |
|
117 if (iProxy && (&obsrvr == iObserver)) |
|
118 { |
|
119 ret = iProxy->RemoveMsgQueueNotifier(EMsgQueueInbandToneType, |
|
120 iObserver); |
|
121 iObserver = NULL; |
|
122 //iProxy->CancelInbandToneNotifier(); |
|
123 } |
|
124 else |
|
125 { |
|
126 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
127 } |
|
128 return ret; |
|
129 } |
|
130 |
|
131 gint TMSInbandToneBodyImpl::Start(TMSInbandToneType inbandtone) |
|
132 { |
|
133 gint ret(TMS_RESULT_SUCCESS); |
|
134 |
|
135 if (iProxy) |
|
136 { |
|
137 ret = iProxy->StartInbandTone(inbandtone); |
|
138 } |
|
139 else |
|
140 { |
|
141 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
142 } |
|
143 return ret; |
|
144 } |
|
145 |
|
146 gint TMSInbandToneBodyImpl::Stop() |
|
147 { |
|
148 gint ret(TMS_RESULT_SUCCESS); |
|
149 if (iProxy) |
|
150 { |
|
151 ret = iProxy->StopInbandTone(); |
|
152 } |
|
153 else |
|
154 { |
|
155 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
156 } |
|
157 return ret; |
|
158 } |
|
159 |
|
160 void TMSInbandToneBodyImpl::SetParent(TMSInbandTone*& parent) |
|
161 { |
|
162 iParent = parent; |
|
163 } |
|
164 |