|
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 <tmsglobalroutingobsrvr.h> |
|
20 #include "tmsutility.h" |
|
21 #include "tmsproxy.h" |
|
22 #include "tmsglobalroutingbodyimpl.h" |
|
23 |
|
24 using namespace TMS; |
|
25 |
|
26 TMSGlobalRoutingBodyImpl::TMSGlobalRoutingBodyImpl() : |
|
27 iObserver(NULL), |
|
28 iProxy(NULL) |
|
29 { |
|
30 } |
|
31 |
|
32 TMSGlobalRoutingBodyImpl::~TMSGlobalRoutingBodyImpl() |
|
33 { |
|
34 if (iProxy) |
|
35 { |
|
36 iProxy->Close(); |
|
37 delete iProxy; |
|
38 iProxy = NULL; |
|
39 } |
|
40 iObserver = NULL; |
|
41 iUserData = NULL; |
|
42 } |
|
43 |
|
44 gint TMSGlobalRoutingBodyImpl::Create(TMSGlobalRoutingBody*& bodyimpl) |
|
45 { |
|
46 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
47 TMSGlobalRoutingBodyImpl* self = new TMSGlobalRoutingBodyImpl(); |
|
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 TMSGlobalRoutingBodyImpl::PostConstruct() |
|
62 { |
|
63 gint ret(TMS_RESULT_SUCCESS); |
|
64 iClientId = 1; |
|
65 iProxy = new TMSProxy; |
|
66 if (iProxy) |
|
67 { |
|
68 if (iProxy->Connect() != TMS_RESULT_SUCCESS) |
|
69 { |
|
70 delete iProxy; |
|
71 iProxy = NULL; |
|
72 ret = TMS_RESULT_FATAL_ERROR; |
|
73 } |
|
74 else |
|
75 { |
|
76 ret = iProxy->StartRoutingNotifier(); //starts TAR |
|
77 } |
|
78 } |
|
79 else |
|
80 { |
|
81 ret = TMS_RESULT_UNINITIALIZED_OBJECT; |
|
82 } |
|
83 return ret; |
|
84 } |
|
85 |
|
86 gint TMSGlobalRoutingBodyImpl::AddObserver(TMSGlobalRoutingObserver& obsrvr, |
|
87 gpointer /*user_data*/) |
|
88 { |
|
89 gint ret(TMS_RESULT_SUCCESS); |
|
90 if (!iObserver) |
|
91 { |
|
92 iObserver = &obsrvr; |
|
93 //iUserData = user_data; |
|
94 if (iProxy) |
|
95 { |
|
96 ret = iProxy->SetMsgQueueNotifier(EMsgQueueGlobalRoutingType, |
|
97 iObserver, NULL, iClientId); |
|
98 } |
|
99 else |
|
100 { |
|
101 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
102 } |
|
103 } |
|
104 else |
|
105 { |
|
106 ret = TMS_RESULT_ALREADY_EXIST; |
|
107 } |
|
108 return ret; |
|
109 } |
|
110 |
|
111 gint TMSGlobalRoutingBodyImpl::RemoveObserver(TMSGlobalRoutingObserver& obsrvr) |
|
112 { |
|
113 gint ret(TMS_RESULT_SUCCESS); |
|
114 if (iProxy && (&obsrvr == iObserver)) |
|
115 { |
|
116 iProxy->RemoveMsgQueueNotifier(EMsgQueueGlobalRoutingType, iObserver); |
|
117 ret = iProxy->CancelRoutingNotifier(); |
|
118 iObserver = NULL; |
|
119 } |
|
120 else |
|
121 { |
|
122 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
123 } |
|
124 return ret; |
|
125 } |
|
126 |
|
127 gint TMSGlobalRoutingBodyImpl::SetOutput(const TMSAudioOutput output) |
|
128 { |
|
129 gint ret(TMS_RESULT_SUCCESS); |
|
130 if (iProxy) |
|
131 { |
|
132 ret = iProxy->SetOutput(output); |
|
133 } |
|
134 else |
|
135 { |
|
136 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
137 } |
|
138 return ret; |
|
139 } |
|
140 |
|
141 gint TMSGlobalRoutingBodyImpl::GetOutput(TMSAudioOutput& output) |
|
142 { |
|
143 gint ret(TMS_RESULT_SUCCESS); |
|
144 if (iProxy) |
|
145 { |
|
146 ret = iProxy->GetOutput(output); |
|
147 } |
|
148 else |
|
149 { |
|
150 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
151 } |
|
152 return ret; |
|
153 } |
|
154 |
|
155 gint TMSGlobalRoutingBodyImpl::GetPreviousOutput(TMSAudioOutput& output) |
|
156 { |
|
157 gint ret(TMS_RESULT_SUCCESS); |
|
158 if (iProxy) |
|
159 { |
|
160 ret = iProxy->GetPreviousOutput(output); |
|
161 } |
|
162 else |
|
163 { |
|
164 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
165 } |
|
166 return ret; |
|
167 } |
|
168 |
|
169 gint TMSGlobalRoutingBodyImpl::GetAvailableOutputs(OutputVector& outputs) |
|
170 { |
|
171 gint ret(TMS_RESULT_SUCCESS); |
|
172 if (iProxy) |
|
173 { |
|
174 ret = iProxy->GetAvailableOutputs(outputs); |
|
175 } |
|
176 else |
|
177 { |
|
178 ret = TMS_RESULT_DOES_NOT_EXIST; |
|
179 } |
|
180 return ret; |
|
181 } |
|
182 |
|
183 // End of file |