|
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 <tmsstream.h> |
|
20 #include "tmscallproxy.h" |
|
21 #include "tmsstreamimpl.h" |
|
22 #include "tmsutility.h" |
|
23 #include "tmscscallbodyimpl.h" |
|
24 |
|
25 using namespace TMS; |
|
26 |
|
27 TMSCSCallBodyImpl::TMSCSCallBodyImpl() |
|
28 { |
|
29 TRACE_PRN_FN_ENT; |
|
30 TRACE_PRN_FN_EXT; |
|
31 } |
|
32 |
|
33 TMSCSCallBodyImpl::~TMSCSCallBodyImpl() |
|
34 { |
|
35 TRACE_PRN_FN_ENT; |
|
36 if (iSession) |
|
37 { |
|
38 iSession->DeleteCall(); |
|
39 iSession->Close(); |
|
40 delete iSession; |
|
41 } |
|
42 TRACE_PRN_FN_EXT; |
|
43 } |
|
44 |
|
45 gint TMSCSCallBodyImpl::Create(TMSCallBody*& bodyimpl) |
|
46 { |
|
47 gint ret(TMS_RESULT_INSUFFICIENT_MEMORY); |
|
48 TMSCSCallBodyImpl* self = new TMSCSCallBodyImpl; |
|
49 |
|
50 TRACE_PRN_FN_ENT; |
|
51 if (self) |
|
52 { |
|
53 ret = self->PostConstruct(); |
|
54 if (ret != TMS_RESULT_SUCCESS) |
|
55 { |
|
56 delete self; |
|
57 self = NULL; |
|
58 } |
|
59 } |
|
60 bodyimpl = self; |
|
61 TRACE_PRN_FN_EXT; |
|
62 return ret; |
|
63 } |
|
64 |
|
65 gint TMSCSCallBodyImpl::PostConstruct() |
|
66 { |
|
67 gint ret(TMS_RESULT_SUCCESS); |
|
68 TRACE_PRN_FN_ENT; |
|
69 |
|
70 iSession = new TMSCallProxy; |
|
71 |
|
72 TRACE_PRN_FN_ENT; |
|
73 if (!iSession) |
|
74 { |
|
75 ret = TMS_RESULT_INSUFFICIENT_MEMORY; |
|
76 } |
|
77 RET_REASON_IF_ERR(ret); |
|
78 |
|
79 if (iSession->Connect() != TMS_RESULT_SUCCESS) |
|
80 { |
|
81 delete iSession; |
|
82 iSession = NULL; |
|
83 ret = TMS_RESULT_FATAL_ERROR; |
|
84 } |
|
85 else |
|
86 { |
|
87 ret = iSession->CreateCall(TMS_CALL_CS); |
|
88 if (ret != TMS_RESULT_SUCCESS) |
|
89 { |
|
90 iSession->Close(); |
|
91 delete iSession; |
|
92 iSession = NULL; |
|
93 ret = TMS_RESULT_FATAL_ERROR; |
|
94 } |
|
95 } |
|
96 RET_REASON_IF_ERR(ret); |
|
97 TRACE_PRN_FN_EXT; |
|
98 return ret; |
|
99 } |
|
100 |
|
101 TMSCallType TMSCSCallBodyImpl::GetCallType() |
|
102 { |
|
103 return TMS_CALL_CS; |
|
104 } |
|
105 |
|
106 gint TMSCSCallBodyImpl::GetCallContextId(guint& ctxid) |
|
107 { |
|
108 gint ret(TMS_RESULT_FEATURE_NOT_SUPPORTED); |
|
109 TRACE_PRN_FN_ENT; |
|
110 ctxid = 0; |
|
111 TRACE_PRN_FN_EXT; |
|
112 return ret; |
|
113 } |
|
114 |
|
115 gint TMSCSCallBodyImpl::CreateStream(TMSStreamType type, TMSStream*& strm) |
|
116 { |
|
117 gint ret(TMS_RESULT_CALL_TYPE_NOT_SUPPORTED); |
|
118 |
|
119 if (strm) |
|
120 { |
|
121 return TMS_RESULT_INVALID_ARGUMENT; |
|
122 } |
|
123 |
|
124 switch (type) |
|
125 { |
|
126 case TMS_STREAM_UPLINK: |
|
127 case TMS_STREAM_DOWNLINK: |
|
128 ret = TMSStreamImpl::Create(TMS_CALL_CS, type, iSession, strm); |
|
129 if (ret == TMS_RESULT_SUCCESS) |
|
130 { |
|
131 ret = AddStreamToList(strm); |
|
132 } |
|
133 //TODO:Need longer term fix to not destory everything |
|
134 //if more then one stream is trying to be created. |
|
135 else if (ret == TMS_RESULT_ALREADY_EXIST) |
|
136 { |
|
137 break; |
|
138 } |
|
139 else |
|
140 { |
|
141 //TODO: delete call only if no active sessions left |
|
142 if (iSession) |
|
143 { |
|
144 iSession->DeleteCall(); |
|
145 iSession->Close(); |
|
146 delete iSession; |
|
147 iSession = NULL; |
|
148 } |
|
149 } |
|
150 break; |
|
151 default: |
|
152 break; |
|
153 } |
|
154 TRACE_PRN_FN_EXT; |
|
155 return ret; |
|
156 } |
|
157 |
|
158 gint TMSCSCallBodyImpl::DeleteStream(TMSStream*& strm) |
|
159 { |
|
160 gint ret(TMS_RESULT_SUCCESS); |
|
161 TRACE_PRN_FN_ENT; |
|
162 ret = RemStreamFromList(strm); |
|
163 TRACE_PRN_FN_EXT; |
|
164 return ret; |
|
165 } |
|
166 |
|
167 gint TMSCSCallBodyImpl::AddStreamToList(TMSStream* strm) |
|
168 { |
|
169 gint ret(TMS_RESULT_SUCCESS); |
|
170 TRACE_PRN_FN_ENT; |
|
171 iStreamsVector.push_back(strm); |
|
172 TRACE_PRN_FN_EXT; |
|
173 return ret; |
|
174 } |
|
175 |
|
176 gint TMSCSCallBodyImpl::RemStreamFromList(TMSStream*& strm) |
|
177 { |
|
178 gint ret(TMS_RESULT_DOES_NOT_EXIST); |
|
179 gint nArraySize = (gint) iStreamsVector.size(); |
|
180 // get an iterator to the start of the array |
|
181 std::vector<TMSStream*>::iterator itStrm = iStreamsVector.begin(); |
|
182 |
|
183 // display the arrays' contents |
|
184 |
|
185 TRACE_PRN_FN_ENT; |
|
186 for (; itStrm < iStreamsVector.end(); itStrm++) |
|
187 { |
|
188 if (strm == *itStrm) |
|
189 { |
|
190 break; |
|
191 } |
|
192 } |
|
193 |
|
194 if (itStrm) |
|
195 { |
|
196 // Remove stream object from the vector. After removing, the iterator |
|
197 // will point to the next item (if available); so, do NOT attempt |
|
198 // deleting itStrm here! (Will result in KERN-EXEC) |
|
199 iStreamsVector.erase(itStrm); // Remove from array |
|
200 delete strm; // Free memory |
|
201 strm = NULL; |
|
202 ret = TMS_RESULT_SUCCESS; |
|
203 } |
|
204 TRACE_PRN_FN_EXT; |
|
205 return ret; |
|
206 } |
|
207 |
|
208 // End of file |